Python GUI2Exe Application Standalone Build (Using Py2Exe)
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 "seleniumwebdriverfirefoxfirefox_profile.pyc", line 63, in __init__
IOError: [Errno 2] No such file or directory: 'C:usersusernamePycharmProjectsPython_27_32bitfile_data_extractdistFile_data_extract.exeseleniumwebdriverfirefoxwebdriver_prefs.json'
It is looking for selenium package is located at : C:UsersusernameAnaconda2_Py27_32bitLibsite-packagesselenium-2.48.0-py2.7.eggseleniumwebdriverfirefox
where C:UsersusernameAnaconda2_Py27_32bit is where I installed Anaconda Python 2.7, 32 bit version. By default it is looking for in distfilename.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
链接地址: http://www.djcxy.com/p/38592.html