2014-03-02 59 views
2

我有一个tkinter应用程序,我正在编译为.exe通过py2exe为什么我得到这个ImportError?

在安装文件,我已经将它设置为包括lxmlurlliblxml.htmlastmath

当我在CMD控制台中运行python setup.py py2exe时,它编译得很好。然后我去到它创建的dist文件夹,然后运行.exe文件。

当我运行.exe我得到这个弹出窗口。 this http://gyazo.com/02fc6000c94c165a696d5072738c676d.png

然后我开始打开Trader.exe.log文件,内容如下:

Traceback (most recent call last): 
    File "Trader.py", line 1, in <module> 
    File "lxml\html\__init__.pyc", line 42, in <module> 
    File "lxml\etree.pyc", line 12, in <module> 
    File "lxml\etree.pyc", line 10, in __load 
    File "lxml.etree.pyx", line 84, in init lxml.etree (src\lxml\lxml.etree.c:190292) 
ImportError: cannot import name _elementpath 

包括here是我setup.py文件的副本。

请帮我看看这里的问题。提前致谢。

+1

这是一个重复我想你可以在这里找到答案http://stackoverflow.com/questions/5308760/py2exe-lxml-woes – PyNEwbie

回答

4

看起来像py2exe没有意识到它应该包含lxml._elementpath模块,该模块由lxml.etree有条件地导入。您可以通过setup.py中的includes关键字参数让它明确包含该模块。

+0

像[this?](https://dl.dropboxusercontent.com/s /58m00rene91z3kf/setup.py) –

+3

添加'lxml._elementpath'模块。你可以在这个主题上找到更多的信息:http://stackoverflow.com/questions/5308760/py2exe-lxml-woes如有必要,尝试使用类似于该问题答案的'setup.py'。 –