重要的包和模块与 py2exe 不兼容?
是否有 py2exe 无法处理的主要/常见/重要包?
我目前正在研究从 Python 程序创建 .exe 的可能性,该程序将使用 Tkinter、一些 Excel 文件读取模块、NumPy、SciPy 和 matplotlib:尝试使用 py2exe 实现这一目标是否现实?
Are there major/common/important packages that py2exe cannot handle?
I am currently studying the possibility of creating a .exe from a Python program that will use Tkinter, some Excel file reading module, NumPy, SciPy and matplotlib: is it realistic to try to achieve this with py2exe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通常使用 Scipy、matplotlib、wxpython 和 win32com 或 Machin 的 xlrd/xlwt 模块构建 py2exe 单文件可执行文件。从未使用过 Tkinter,但应该不是问题,可能 wxpython 更挑剔。
我在构建可执行文件之前和之后发现了 numpy/scipy、matplotlib 和 wxpython 的一些问题,但在您知道该怎么做之后,它就可以顺利工作了。
一些问题:
matplotlib 需要指出一些辅助档案的位置。您需要添加到 setup.py 中,
在执行 py2exe 可执行文件时,由于模块中的一些表达式,numpy/scipy 给我带来了一些问题。
Numpy 有一些行,例如:
当
__doc__
为 None 时失败。为此,我必须手动修改 numpy 脚本(包括 if )。不知道新版本是否解决了这个问题。
wxpython 通常是问题的根源,因为计算机中必须存在一些必需的 microsoft dll 才能工作。只是您必须小心,确保在包中提供它们,或者至少阻止您的用户了解该问题。
一些有用的提示也可以在 py2exe 和 wxpython 维基
I routinely build py2exe single file executables using Scipy, matplotlib, wxpython and win32com or the Machin's xlrd/xlwt modules. Never used Tkinter but should not be a problem, probably wxpython is more picky.
I have found some problems with numpy/scipy, matplotlib and wxpython before and after building the executable but after you know what to do it works smoothy.
Some problems:
matplotlib requires to indicate where some auxiliary archives are. You need to add to your setup.py
numpy/scipy have given me some problems, due to some expresions in the modules, when executing the py2exe executable.
Numpy has some lines suchs as:
that fail when
__doc__
is None.For this I had to modify manually the numpy scripts (including if's). I do not know if this has been solved in the new versions.
wxpython is generally a source of problems due to some required microsoft dlls that have to be present in the computer to work. Just you have to be carefull assuring you provide them in your package or at least preventing your users about the issue.
Some useful hints can also be found in the py2exe and wxpython wikis
当然,尝试是现实的。您可能会遇到一些问题,但我怀疑您会遇到阻碍,尤其是对于非常常见的软件包。
您可以在这里快速了解 py2exe 与各种库的配合情况:
http://www. py2exe.org/index.cgi/WorkingWithVariousPackagesAndModules
对于此处未列出的任何内容,请快速搜索
py2exe
It's realistic to try, sure. You'll probably hit a few issues but I doubt you'll reach a blocker, especially with very common packages.
You can get a quick look at how well py2exe works with various libraries here:
http://www.py2exe.org/index.cgi/WorkingWithVariousPackagesAndModules
For anything not listed there, fire off a quick google for
py2exe <package-name>