tags:

views:

41

answers:

0

I have a Python application that loads python modules dynamically at run time (using __import__). The modules to load are in a package called 'plugins' (i.e. subfolder called plugins with __init__.py etc). All works fine running from the python interpreter, and even when compiled to a windows binary using py2exe.

I tried building a OSX app from it, which succeeded, but when running the .app I get an ImportError: 'no module named plugins.xxxx'.

I am pretty sure I gave the correct options to py2app ('includes': [...], 'packages':['plugins'], identical to what I do for py2exe), since when I browse the .app content, I see all the plugin modules in a folder Contents/Resources/lib/python2.5/plugins/.

So, why can't the app find my modules (must be some path issue)?

Edit:

I've found a way to make it work, but it isn't a good solution: When I printed the paths Python searches for modules (using print sys.path), I noticed that the folder Contents/Resources/lib/python2.5/plugins/ was NOT listed. However, the folder Contents/Resources/ is, so I moved the plugins folder to the Contents/Resources folder. Now the plugins are found. But I am still not happy with this ugly, manual hack.