简体   繁体   English

Py2Exe-找不到模块

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM