cx_freeze如何包含第三方模块,ImportError:没有名为progressbar的模块

时间:2014-03-01 15:33:35

标签: python packages py2exe pyinstaller cx-freeze

我在使用cx_freeze时遇到了一个问题,如何“包含”第三方模块或包?根据文件,这似乎很容易但...... 我的环境:win7 x64 python 2.7.5 x64

这是我的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')]
)

我遇到问题,包括我通过pip安装的软件包progressbar

这是我简化的.py主程序

#!/usr/bin/env python2

# from progressbar import FileTransferSpeed,Percentage,ETA,Bar,ProgressBar
# print FileTransferSpeed

import progressbar
print "yeah !"

即使这两行代码,在运行cxfreeze myTool.py之后,我仍然会看到丑陋的模块警告

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.

当然,当我运行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

我错过了什么?

>>> import progressbar
>>> progressbar
<module 'progressbar' from 'C:\Python27\lib\site-packages\progressbar-2.3-py2.7.egg\progressbar\__init__.pyc'>

编辑:holycrap我找到了原因,我忘了安装这个软件包时,不知道如何通过pip命令安装最新的2.3-dev版本,试过pip install progressbar=2.3-dev,所以我下载了源代码并运行{ {1}},所以我最终得到了site-packages中的.egg文件,我卸载它并使用pip安装了另一个progressbar2包,界面似乎相同,现在cx_freeze正常工作。 (因为软件包安装在site-packages中的atcually文件夹中,而不是.egg文件中)

0 个答案:

没有答案