0

So I have been writing this game for a while now and finally have it finished. However due to the fact that the game is meant for a class and I used libraries that my teacher isn't going to bother installing I need to make a single executable that will run independent of python and the games dependencies. I ran py2exe and it completed successfully however when I run the exe I get this error:

Traceback (most recent call last):
  File "main.pyw", line 1, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "libs\__init__.pyo", line 3, in <module>
WindowsError: [Error 3] The system cannot find the path specified: 'C:\\Users\\matt\\workspace\\COS125\\src\\dist\\includes.zip\\libs/*.*'

I have figured out what the most likely cause of the error is. It most likely stems from the auto importer I have installed for each package. In the init.py files for my packages I use the following code so that a simple "from libs import *" will import all the files in the lib package. This will make it so that each file will be loaded as if I loaded each one as "from libs.module import *".

The code in the init file is as follows:

import os, sys
path = os.path.dirname(__file__)
dirList = os.listdir(path)
for mod in dirList:
    ext = os.path.splitext(mod)
    mod = mod[:-len(ext[1])]
    if (mod not in dir() and 
        mod != "__init__" and
        mod != "" and
        mod != "._"):
        exec("from " + mod + " import *")

Essentially what I am asking is if anyone else knows how to do this without resulting in that error after compiling?

  • It looks like there's a problem with the final slash after `libs` - it points the other way from all the other path separators... – ire_and_curses Apr 28 '11 at 20:54

1 Answers1

0

I think I ran into a similar problem a couple years ago, and I solved it by getting rid of zip files in the distribution.

With py2exe options, try setting zipfile=None or maybe turn off compression and turn off bundling.

Note that creating a Windows exe that will run on all Windows OS's is a pain. I got good feedback on this from the py2exe list here and here.

new name
  • 15,861
  • 19
  • 68
  • 114
  • I tried with no zip file first, and then when that didn't work I tried this. It was the same error both times. – MattyP92 May 03 '11 at 04:36