Zac*_*tes 7 python lxml py2exe importerror lxml.html
我有一个tkinter
正在编译为.exe
via 的应用程序py2exe
。
在安装文件中,我将其设置为包含lxml
、urllib
、lxml.html
、ast
和math
。
当我python setup.py py2exe
在 CMD 控制台中运行时,它编译得很好。然后我转到dist
它创建的文件夹,并运行该.exe
文件。
当我运行时,.exe
我得到这个弹出窗口。
(来源:gyazo.com)
然后我继续打开该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
Run Code Online (Sandbox Code Playgroud)
这里包括我的文件的副本setup.py
。
请帮我找到这里的问题。提前致谢。
看起来py2exe
没有意识到它应该包含该lxml._elementpath
模块,该模块是由 . 有条件导入的lxml.etree
。includes
您可以告诉它使用关键字参数显式包含该模块setup.py
。
setup(
options={'py2exe': {"includes": ["lxml._elementpath"]}}
)
Run Code Online (Sandbox Code Playgroud)