Py2exe lxml 问题
我有一个 wxpython 应用程序,它依赖于 lxml,并且在通过 python 解释器运行时运行良好。但是,当使用 py2exe 创建 exe 时,我收到此错误
ImportError: No module named _elementpath
,然后我使用 python setup.py py2exe -p lxml ,但没有收到上述错误 另一位说
ImportError: No module named gzip
谁能让我知道问题是什么以及如何解决它。我还应该放任何 我的 dist 文件夹中是否有 libxml2、libxslt 等 dll 文件?我搜了一下电脑 并且没有找到这些文件,所以也许不需要它们?
谢谢。
编辑:我刚刚尝试使用 python setup.py py2exe -p -i gzip 并创建了 exe。但生成的exe无法运行。我双击它,但它没有执行任何操作。
setup.py 脚本
from py2exe.build_exe import py2exe
from distutils.core import setup
setup( windows=[{"script": "gui.py"}] )
这是我正在使用的
Edit2:我尝试使用 cx_freeze 作为替代方案,但遇到了相同的
ImportError: No module named _elementpath
错误。之后不知道如何进行。
I have a wxpython application that depends on lxml and works well when running it through the python interpreter. However, when creating an exe with py2exe, I got this error
ImportError: No module named _elementpath
I then used python setup.py py2exe -p lxml
and I did not get the above error but
another one saying
ImportError: No module named gzip
Could anyone let me know what the problem is and how I can fix it. Also should I put any
dll files like libxml2, libxslt etc in my dist folder? I searched the computer
and did not find these files, so maybe they aren't needed?
Thanks.
Edit: I just tried with python setup.py py2exe -p -i gzip
and the exe was created. But the exe generated does not run. I double click it and it doesn't do anything.
Here's the setup.py script i'm using
from py2exe.build_exe import py2exe
from distutils.core import setup
setup( windows=[{"script": "gui.py"}] )
Edit2: I tried using cx_freeze as an alternative , but got the same
ImportError: No module named _elementpath
error. Didn't know how to proceed after that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Py2exe 允许您指定其他包/模块,以包含在
setup()
的options
参数中,以防它们未被自动检测到。以下内容应该有效:我最近还发现了 PyInstaller,它内置了对许多良好的支持- 已知的软件包,包括 lxml,因此也值得一试。
Py2exe allows you to specify additional packages/modules to include with the
options
argument tosetup()
, in case they are not automatically detected. The following should work:I've also recently discovered PyInstaller, which has built-in support for a number of well-known packages, including lxml, so that might be worth a try as well.
有时,修改
setup.py
文件后,您需要执行更多操作。如此处所述,
如果该软件包安装在“eggs”存档上,则需要卸载该软件包。
然后通过强制 easy_install 使用“-Z”选项解压缩存档来再次安装它,如下所示(我遇到了 paramiko 包的问题):
Sometimes you will need to do another action more after modify the
setup.py
file.As described here,
it should be necessary to uninstall the package if it is installed on "eggs" archive.
Then install it again by forcing easy_install to dezip the archive with the "-Z" option as following (I had the issue with paramiko package):