Python GUI2Exe应用程序独立构建(使用Py2Exe) [英] Python GUI2Exe Application Standalone Build (Using Py2Exe)

查看:175
本文介绍了Python GUI2Exe应用程序独立构建(使用Py2Exe)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Python脚本构建到独立的应用程序中.我正在使用GUI2Exe.我的脚本使用了硒包.我已经安装了. 项目可以正常编译并直接在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中,您可以找到带有所有包含selenium和sendkeys包含包的project_name_script.exe.分发软件包时,您需要分发整个project_name,因为它包含所有依赖的库dll(python .pyd).

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

I am trying to build a Python Script into a stand alone application. I am using GUI2Exe. My script uses selenium package. I have it installed. Project compiles fine and runs on python command line directly but fails to build a stand alone because it is referring to folder:

 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'

It is looking for selenium package is located at : C:\Users\username\Anaconda2_Py27_32bit\Lib\site-packages\selenium-2.48.0-py2.7.egg\selenium\webdriver\firefox

where C:\Users\username\Anaconda2_Py27_32bit is where I installed Anaconda Python 2.7, 32 bit version. By default it is looking for in \dist\filename.exe folder.

解决方案

I was able to build it using bbfreeze. It works great.

First I had to install bbfreezee via pip (one time only):

pip install bbfreeze

Create a build_package.py file as:

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

Build project:

python build_package.py bdist_bbfreezee

in folder project_name where project_name_script.py sits you find project_name_script.exe with all the include packages including selenium and sendkeys. When you distribute the package you need to distribute entire project_name because it contains all dependent library dlls (python .pyd).

More details refer official bbfreezee here: https://pypi.python.org/pypi/bbfreeze/#downloads

这篇关于Python GUI2Exe应用程序独立构建(使用Py2Exe)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆