繁体   English   中英

Python GUI2Exe应用程序独立构建(使用Py2Exe)

[英]Python GUI2Exe Application Standalone Build (Using Py2Exe)

我正在尝试将Python脚本构建到独立的应用程序中。 我正在使用GUI2Exe。 我的脚本使用了硒包。 我已经安装了。 Project可以正常编译并直接在python命令行上运行,但由于指向文件夹而无法构建独立的项目:

 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 \\用户名\\ Anaconda2_Py27_32bit \\ Lib \\ site-packages \\ selenium-2.48.0-py2.7.egg \\ selenium \\ webdriver \\ firefox

其中C:\\ Users \\ username \\ Anaconda2_Py27_32bit是我安装Anaconda Python 2.7(32位版本)的位置。 默认情况下,它在\\ dist \\ filename.exe文件夹中寻找。

我能够使用bbfreeze构建它。 效果很好。

首先,我必须通过pip安装bbfreezee(仅一次):

pip install 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和sendkeys的包。 分发软件包时,您需要分发整个project_name,因为它包含所有依赖的库dll(python .pyd)。

有关更多详细信息,请参见此处的官方bbfreezee: https ://pypi.python.org/pypi/bbfreeze/#downloads

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM