Using the PathModule from Jason Jorendorff,, which is called by Py2Exe, gets into an endless recursion.

It tries to resolve os.path, gets to  os.os.path , further to  os.os.path  and breaks somewhere at os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.path  at which point you get a RuntimeError: maximum recursion depth exceeded.

(Maybe it would be a test to use StackLess Python, it would run forever or until the maximum string length of pyhton is reached. But maximum string length in Python is only limited by memory, memory is limited by address-space ... )

But apart from joking: it is IMPOSSIBLE to generate an exe with the modern 0.5 Version of Py2Exe when is installed.


Just rename




and make sure also to toggle your imports to

   1 import jpath

and to delete path.pyc and path.pyo from your site-packages directory.


Possible Bugfix

This patch to Lib/ should fix the problem, it would be nice if people would try it out, and report back here:

   1 Index:
   2 ===================================================================
   3 RCS file: /cvsroot/python/python/dist/src/Lib/,v
   4 retrieving revision
   5 diff -c -r1.7.6.1
   6 ***     14 Nov 2003 10:23:03 -0000
   7 ---     30 Mar 2004 18:54:01 -0000
   8 ***************
   9 *** 245,250 ****
  10 --- 245,253 ----
  11           if self.badmodules.has_key(fqname):
  12               self.msgout(3, "import_module -> None")
  13               return None
  14 +         if parent and parent.__path__ is None:
  15 +             self.msgout(3, "import_module -> None")
  16 +             return None
  17           try:
  18               fp, pathname, stuff = self.find_module(partname,
  19                                                      parent and parent.__path__, parent)

Works for me on a simple test -- Paul Moore
Works for me -- Maxime Vernier
Works for me too -- Matteo Bertini

PathModul (last edited 2008-07-08 11:27:43 by localhost)