i came across a problem when using cx_freeze, how to "include" 3rd 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 = '[email protected]',
options = {'build_exe': {'includes':includes,'excludes':excludes,'packages':packages,'include_files':includefiles}},
executables = [Executable('myTool.py')]
)
and i had problem including the package progressbar i 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 !"
with even these two lines of code, after running cxfreeze myTool.py, i still got the ugly missing modules warning
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, don't know how to install latest 2.3-dev version via pip command , tried pip install progressbar=2.3-dev
, so i downloaded the source and ran easy_install setup.py install
, so i end up with .egg file in site-packages, i uninstalled it and installed another progressbar2 package using pip, interface seems the same, now cx_freeze works. ( because the package is installed into atcually folders in site-packages, not a .egg file )