Py2Exe和Easgui [英] Py2Exe and Easgui
问题描述
我正在尝试将py文件转换为exe. 这是我的安装文件的代码
I am trying to convert a py file to an exe. Here is the code for my setupfile
from distutils.core import setup
import py2exe
setup(console=["mycode.py"])
当我使用cmd时,它说: 导入错误:没有名为easygui的模块
When I use cmd, it says: Import Error: No module named easygui
我如何让py2exe知道easygui?以及numpy和mathplotlib(都在mycode.py中使用)
How do I let py2exe know about the easygui? As well as the numpy and mathplotlib (all are used in mycode.py)
推荐答案
首先,使用 pyinstaller .它是新的和更好的(尽管我一直使用py2exe直到切换到pyinstaller为止),而且似乎有更好的配方来查找您包含的库.
First, use pyinstaller. It is newer and better (though I have used py2exe until switching to pyinstaller) And it seems to have much better recipes for finding your included libs.
但是对于py2exe,您需要进一步扩展setup.py才能告诉它要包含的内容(因为它们可能是隐藏的导入内容)
But for py2exe, you will need to expand that setup.py a bit more to tell it what to include (since they are probably hidden imports)
setup(
console=["mycode.py"],
options={
"py2exe": {
"includes": ["easygui"],
"bundle_files": 1
},
},
zipfile = None,
)
如果此操作无法生成,则easygui
不在您的PYTHONPATH中.确保您没有在脚本中做一些特殊的事情来添加pythonpath,而py2exe无法看到它.
If this fails to build, then easygui
is not in your PYTHONPATH properly. Make sure you are not doing something special in your script to add a pythonpath, which would not be visible to py2exe.
对于numpy和matplotlib,您可能需要对该文件做更多的工作.请参见此Wiki以获取帮助
You may need to do a little more work with this file for numpy and matplotlib. See this wiki for help
这篇关于Py2Exe和Easgui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!