Python GUI2Exe应用程序独立构建(使用Py2Exe)
我正在尝试将Python脚本构建到一个独立的应用程序中。我正在使用GUI2Exe。我的脚本使用selenium包。我已经安装好了。 Project编译良好,直接在python命令行上运行,但无法构建独立的,因为它引用的是文件夹:Python GUI2Exe应用程序独立构建(使用Py2Exe),python,selenium,py2exe,gui2exe,python-standalone,Python,Selenium,Py2exe,Gui2exe,Python Standalone,我正在尝试将Python脚本构建到一个独立的应用程序中。我正在使用GUI2Exe。我的脚本使用selenium包。我已经安装好了。 Project编译良好,直接在python命令行上运行,但无法构建独立的,因为它引用的是文件夹: ERROR: test_file_data_extract (__main__.FileDataExtract) ---------------------------------------------------------------------- Trac
ERROR: test_file_data_extract (__main__.FileDataExtract)
----------------------------------------------------------------------
Traceback (most recent call last):
File "File_data_extract.py", line 18, in setUp
File "selenium\webdriver\firefox\firefox_profile.pyc", line 63, in __init__
IOError: [Errno 2] No such file or directory: 'C:\\users\\username\\PycharmProjects\\Python_27_32bit\\file_data_extract\\dist\\File_data_extract.exe\\selenium\\webdriver\\firefox\\webdriver_prefs.json'
正在寻找的硒包装位于:
C:\Users\username\Anaconda2\u Py27\u 32bit\Lib\site packages\selenium-2.48.0-py2.7.egg\selenium\webdriver\firefox
其中C:\Users\username\Anaconda2\u Py27\u 32位是我安装Anaconda Python 2.7的32位版本的地方。默认情况下,它在\dist\filename.exe文件夹中查找。我可以使用bbfreeze构建它。它工作得很好 首先,我必须通过pip安装BBfreeze(仅一次): 创建build_package.py文件,如下所示:
from bbfreeze import Freezer
f = Freezer("project_name", includes=("selenium","SendKeys",)) #list problem packages here to manually include
f.addScript("project_name_script.py")
f() # starts the freezing process
建设项目:
python build_package.py bdist_bbfreezee
在project_name_script.py所在的文件夹project_name中,您可以找到project_name_script.exe以及包括selenium和sendkey在内的所有include包。分发包时,需要分发整个项目名称,因为它包含所有依赖库DLL(python.pyd)
更多详细信息请参见此处的官方BBE:
python build_package.py bdist_bbfreezee