Milano
Milano

Reputation: 18745

Py2Exe - can't find modules

I want to create an exe file using Py2exe module. The problem is that the exe file says that there is not os module. I've put it into includes in setup.py file so it should work.

Here is the error after run main.exe created by 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:

from distutils.core import setup
import py2exe

    setup(console=["main.py"],options = {
              "py2exe":{
                  "includes": ["os","linecache"]
                  }
              },)

Upvotes: 1

Views: 4715

Answers (1)

mabe02
mabe02

Reputation: 2744

The problem is that if you want to import packages, you should use the option packages and not includes. The first one imports libraries, the second modules.py.This should work now:

from distutils.core import setup
import py2exe

    setup(console=["main.py"], 
         options = {
              "py2exe":{
                  "packages": ["os","linecache"]
                  }
              })

Upvotes: 2

Related Questions