[英]Py2Exe - can't find modules
I want to create an exe file using Py2exe
module. 我想使用
Py2exe
模块创建一个exe文件。 The problem is that the exe file says that there is not os
module. 问题是exe文件说没有
os
模块。 I've put it into includes
in setup.py
file so it should work. 我已经将它放入
setup.py
文件中的includes
中,因此它应该可以工作。
Here is the error after run main.exe
created by Py2Exe
下面是运行后的错误
main.exe
通过创建Py2Exe
import linecache
ImportError: No module named linecache
Traceback (most recent call last):
File "main.py", line 3, in <module>
ImportError: No module named os
And here is my setup.py
: 这是我的
setup.py
:
from distutils.core import setup
import py2exe
setup(console=["main.py"],options = {
"py2exe":{
"includes": ["os","linecache"]
}
},)
The problem is that if you want to import packages, you should use the option packages
and not includes
. 问题在于,如果要导入软件包,则应使用选项
packages
而不要includes
。 The first one imports libraries
, the second modules.py
.This should work now: 第一个导入
libraries
,第二个模块modules.py
现在应该可以使用:
from distutils.core import setup
import py2exe
setup(console=["main.py"],
options = {
"py2exe":{
"packages": ["os","linecache"]
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.