I've been reading through the py2exe source, but so far no luck in finding something that will help me.

It looks like I have a lot more reading to do. Thanks for the help.

On Mon, Aug 8, 2011 at 8:37 AM, Mark Hammond <mhammond@skippinet.com.au> wrote:
If your exe is a console program, try setting a PYTHON_VERBOSE env var - you should see lots of output about what is being looked at to resolve an import.

It may well be that py2exe pulls more tricks than I can remember so an import hook is your only option, but I think the above should help either way...


On 8/08/2011 9:22 PM, Adam Estes wrote:
This is the contents of sys,path  from the .exe

['C:\\Program Files\\Neocodex\\Manager\\pre_loader.exe', 'C:\\Program
Files\\Neocodex\\Manager', 'C:\\Program Files\\Neocodex\\Manager/Lib']

(I removed the importing of every single directory inside Lib to reduce
the spam)

It shows the proper Lib Directory, as it should.

The specific error is:

Traceback (most recent call last):
  File "pre_loader.py", line 66, in <module>
  File "__init__.pyo", line 8, in <module>
  File "ProgramManager.pyo", line 35, in <module>
  File "rpdb2.pyo", line 13487, in rpdb2_import_wrapper
  File "PluginManager.pyo", line 9, in <module>
  File "rpdb2.pyo", line 13487, in rpdb2_import_wrapper
ImportError: No module named GeneralFunctions

Which is this line

from GeneralFunctions import *

And GeneralFunctions is a folder inside of the Lib folder containing


Do you need anything else?

On Mon, Aug 8, 2011 at 7:08 AM, King Simon-NFHD78
<mailto:simon.king@motorolasolutions.com>> wrote:

    > -----Original Message-----
    > From: Adam Estes [mailto:iargue@neocodex.us
    > Sent: 08 August 2011 11:55
    > Subject: Re: [Py2exe-users] Python and independent modules
    > I used the following code
    > path = os.getcwd()
    > sys.path.append(path)
    > sys.path.append(path + '/Lib')
    > path2 = os.walk(path + '/Lib')
    > for dirpath, dirnames, filenames in path2:
    >     sys.path.append(path + dirpath)
    > To add everything in the lib folder to the sys path. Everything works
    > perfectly, until we compile it, and then it doesn't work. :(

   Have you tried printing out sys.path after you've appended those
   directories (in the py2exe-d version)? There are a couple of potential
   problems with your approach:

   a) I don't think os.getcwd() is guaranteed to return the directory
   containing your .exe. You'd be better off using one of the suggestions
   on http://www.py2exe.org/index.cgi/WhereAmI

   b) I think os.getcwd() will return an absolute path, which means that
   'dirpath' in your 'for' loop will also be an absolute path. 'path +
   dirpath' will therefore be invalid. In general you should use
   os.path.join to do these kinds of path manipulations.

   If neither of these suggestions fix your problem, perhaps you could show
   us the contents of sys.path and the exact error message, and we might be
   able to help further.