gpt4 book ai didi

python - 使用 Selenium 模块创建 Exe : Py2exe/Pyinstaller

转载 作者:太空狗 更新时间:2023-10-29 20:30:31 26 4
gpt4 key购买 nike

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

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

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

最佳答案

试试这个:

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

关于python - 使用 Selenium 模块创建 Exe : Py2exe/Pyinstaller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30589329/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com