I encountered a problem when using cx_freeze, how to "enable" third-party modules or packages? according to the doc, it seems easy, but ... my env: win7 x64 python 2.7.5 x64
here is my setup.py
#!/usr/bin/env python2 from cx_Freeze import setup, Executable includefiles = [] includes = [] excludes = [] packages = ["lxml","lxml._elementpath","lxml.etree","lxml.html",'selenium','jinja2', "progressbar"] setup( name = 'myTool', version = '0.1', description = 'Brought to you by xxx', author = 'tool', author_email = ' tool@me.com ', options = {'build_exe': {'includes':includes,'excludes':excludes,'packages':packages,'include_files':includefiles}}, executables = [Executable('myTool.py')] )
and I had a problem including the progressbar i package installed via pip.
here is my simplified .py main program
#!/usr/bin/env python2 # from progressbar import FileTransferSpeed,Percentage,ETA,Bar,ProgressBar # print FileTransferSpeed import progressbar print "yeah !"
even with these two lines of code, after running cxfreeze myTool.py, I still got a warning about the ugly missing modules
Missing modules: ? _emx_link imported from os ? cStringIO imported from encodings.quopri_codec, encodings.uu_codec, quopri ? ce imported from os ? getopt imported from base64, quopri ? org.python.core imported from copy ? os.path imported from os ? os2 imported from os ? os2emxpath imported from os ? posix imported from os ? progressbar imported from __main__ ? pwd imported from posixpath ? re imported from base64, encodings.idna, posixpath, string, warnings ? riscos imported from os ? riscosenviron imported from os ? riscospath imported from os ? subprocess imported from os This is not necessarily a problem - the modules may not be needed on this platfo rm.
of course when i run dist\myTool.exe
E:\cxfreeze\progressbar_test>dist\myTool.exe Traceback (most recent call last): File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27 , in <module> exec code in m.__dict__ File "myTool.py", line 6, in <module> import progressbar ImportError: No module named progressbar
What am I missing?
>>> import progressbar >>> progressbar <module 'progressbar' from 'C:\Python27\lib\site-packages\progressbar-2.3-py2.7.egg\progressbar\__init__.pyc'>
edit: holycrap I found the reason, I forgot when I installed this package, I donβt know how to install the latest version 2.3-dev using the pip command, I tried pip install progressbar=2.3-dev , so I downloaded the source and ran easy_install setup.py install , so I ended up with the .egg file in the site packages, I uninstalled it and installed another progressbar2 package using pip, the interface seems the same, cx_freeze now works. (because the package is installed in folders in the folders of the site, and not in the .egg file)