【问题标题】:Creating an Exe with Selenium Module: Py2exe/Pyinstaller使用 Selenium 模块创建 Exe:Py2exe/Pyinstaller
【发布时间】:2015-08-15 20:19:46
【问题描述】:

我到处找。 Stackoverflow、各种留言板、py2exe 网站、pyinstaller 网站……没有任何帮助。包括 selenium 模块,特别是制作一个支持 firefox 的 exe,似乎是不可能的。我开始拔头发了,因为使用 py2exe 和 pyinstaller 变得非常头疼。

py2exe 和 pyinstaller 都有各自的问题。

我的目标是制作单个 exe 文件,没有任何额外的目录,以便其他人在没有 python/modules 的情况下可以使用我的程序。

使用 py2exe,如果我这样创建 setup.py 文件

from distutils.core import setup
import py2exe

setup(
name='Ask Alfred',
data_files = [('Drivers', ['Drivers/chromedriver.exe',
             'Drivers/webdriver.xpi','Drivers/webdriver_prefs.json'])],
version='1.0',
description='Find emails fast!',
author='Me',
windows=[{'script': 'alphy.py'}],
options={
    'py2exe':
        {
            'skip_archive': False,
            'optimize': 2,
        }
}
)

它将在 dist 文件夹和 Drivers 文件夹中创建一个包含我需要的文件的 exe,但是,如果我尝试运行该 exe,它会告诉我它找不到这些文件(因为它正在寻找它们library.zip 文件夹)。最重要的是,我的 GUI 看起来很糟糕(字体现在是灰色而不是黑色,白色背景的图像现在有灰色背景)。

使用 pyinstaller,如果我在创建 exe 时使用“--onefile”标志,它根本不起作用/firefox 和 chrome 都不会启动。

如果我选择不存档/不制作一个文件,我只会得到可行的结果。在这种情况下,pyinstaller 提供了一个完整的解决方案。

【问题讨论】:

    标签: python selenium py2exe pyinstaller


    【解决方案1】:

    试试这个:

    options={
        'py2exe':
            {
                'skip_archive': True,
                'unbuffered': True,
                'bundle_files': 2, #assuming you dont want to include the python interpreter
                'optimize': 2,
            },
    },
    zipfile = None
    

    【讨论】:

    • no ... 你不能使用 skip_archive 和 zipfile=None ;-(
    猜你喜欢
    • 1970-01-01
    • 2011-09-18
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2019-08-09
    • 2022-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多