为什么我会有这种恐惧感?

2024-05-18 23:30:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个tkinter应用程序,我正在通过py2exe编译成一个.exe应用程序。

在安装文件中,我将其设置为包括lxmlurlliblxml.htmlastmath

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

当我运行.exe时,我得到这个弹出窗口。this
(来源: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

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

请帮我在这里找到问题。提前谢谢。


Tags: 文件inpy应用程序htmlsetuplineexe
2条回答

看起来py2exe没有意识到它应该包含lxml._elementpath模块,该模块由lxml.etree有条件地导入。您可以告诉它在您的setup.py中显式地使用includes关键字参数包含该模块。

setup(
    options={'py2exe': {"includes": ["lxml._elementpath"]}}
)

Py2exe已经在这个页面上记录了这个错误:http://www.py2exe.org/index.cgi/WorkingWithVariousPackagesAndModules

它们也提供了一个可行的解决方案。

相关问题 更多 >

    热门问题