[Pythonmac-SIG] How does py2app decide what to use as a sys.path?

Richard Bronosky BrunosJunk at Bronosky.com
Wed Oct 24 18:09:51 CEST 2007


I can't figure out how to get py2app to include the site-package dir
where my wx is located.  Here is a transcript of a simple test I ran.

Please advise.

/tmp$ cat py2app-test.py
#!/usr/bin/env python

import sys;
print "Python Version:", sys.version
print "Python Path:", sys.path

import wx

/tmp$ ./py2app-test.py
Python Version: 2.4.4 (#1, Aug 18 2007, 11:05:26)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)]
Python Path: ['/private/tmp',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/geopy-0.93-py2.4.egg',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/UNKNOWN-0.0.0-py2.4.egg',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/configobj-4.4.0-py2.4.egg',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app-0.3.6-py2.4.egg',
'/Users/rbronosky/Code/python/site-packages',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python24.zip',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat-darwin',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat-mac',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat-mac/lib-scriptpackages',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages',
'/opt/local/lib/python2.4/site-packages',
'/opt/local/lib/python2.4/site-packages/Numeric',
'/opt/local/lib/python2.4/site-packages/PyObjC',
'/opt/local/lib/python2.4/site-packages/wx-2.8-mac-unicode']

/tmp$ py2applet -A ./py2app-test.py
running py2app
creating /private/tmp/tmp0GHZAP/build
creating /private/tmp/tmp0GHZAP/build/bdist.macosx-10.3-i386
creating /private/tmp/tmp0GHZAP/build/bdist.macosx-10.3-i386/python2.4-standalone
creating /private/tmp/tmp0GHZAP/build/bdist.macosx-10.3-i386/python2.4-standalone/app
creating /private/tmp/tmp0GHZAP/build/bdist.macosx-10.3-i386/python2.4-standalone/app/collect
creating /private/tmp/tmp0GHZAP/build/bdist.macosx-10.3-i386/python2.4-standalone/app/temp
creating /private/tmp/tmp0GHZAP/dist
creating build/bdist.macosx-10.3-i386/python2.4-standalone/app/lib-dynload
creating build/bdist.macosx-10.3-i386/python2.4-standalone/app/Frameworks
*** creating application bundle: py2app-test ***
creating /private/tmp/py2app-test.app
creating /private/tmp/py2app-test.app/Contents
copying /private/tmp/tmp0GHZAP/dist/py2app-test.app/Contents/Info.plist
-> /private/tmp/py2app-test.app/Contents
creating /private/tmp/py2app-test.app/Contents/MacOS
copying /private/tmp/tmp0GHZAP/dist/py2app-test.app/Contents/MacOS/py2app-test
-> /private/tmp/py2app-test.app/Contents/MacOS
linking /private/tmp/py2app-test.app/Contents/MacOS/python ->
/opt/local/Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/MacOS/Python
copying /private/tmp/tmp0GHZAP/dist/py2app-test.app/Contents/PkgInfo
-> /private/tmp/py2app-test.app/Contents
creating /private/tmp/py2app-test.app/Contents/Resources
copying /private/tmp/tmp0GHZAP/dist/py2app-test.app/Contents/Resources/__boot__.py
-> /private/tmp/py2app-test.app/Contents/Resources
copying /private/tmp/tmp0GHZAP/dist/py2app-test.app/Contents/Resources/__error__.sh
-> /private/tmp/py2app-test.app/Contents/Resources
creating /private/tmp/py2app-test.app/Contents/Resources/lib
creating /private/tmp/py2app-test.app/Contents/Resources/lib/python2.4
linking /private/tmp/py2app-test.app/Contents/Resources/lib/python2.4/config
-> /opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/config
linking /private/tmp/py2app-test.app/Contents/Resources/lib/python2.4/site.py
-> ../../site.py
linking /private/tmp/py2app-test.app/Contents/Resources/PythonApplet.icns
-> /opt/local/Library/Frameworks/Python.framework/Versions/2.4/Resources/Python.app/Contents/Resources/PythonApplet.icns
copying /private/tmp/tmp0GHZAP/dist/py2app-test.app/Contents/Resources/site.py
-> /private/tmp/py2app-test.app/Contents/Resources
copying /private/tmp/tmp0GHZAP/dist/py2app-test.app/Contents/Resources/site.pyc
-> /private/tmp/py2app-test.app/Contents/Resources

/tmp$ tail -n 0 -f /Library/Logs/Console/$(id -u)/console.log & open
py2app-test.app
[1] 14464

/tmp$ Python Version: 2.4.4 (#1, Aug 18 2007, 11:05:26)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)]
Python Path: ['/private/tmp',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/geopy-0.93-py2.4.egg',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/UNKNOWN-0.0.0-py2.4.egg',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/configobj-4.4.0-py2.4.egg',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app-0.3.6-py2.4.egg',
'/private/tmp/py2app-test.app/Contents/Resources',
'/tmp/py2app-test.app/Contents/Resources',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python24.zip',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat-darwin',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat-mac',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat-mac/lib-scriptpackages',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload',
'/tmp/py2app-test.app/Contents/Resources/lib/python2.4/site-packages.zip',
'/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages',
'/Users/rbronosky/Library/Python/2.4/site-packages', '/private/tmp']
Traceback (most recent call last):
  File "/tmp/py2app-test.app/Contents/Resources/__boot__.py", line 157, in ?
    _run(('\x00\x00\x00\x00\x01\x16\x00\x02\x00\x00\x0cMacintosh
HD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc2\xca\xa1qH+\x00\x00\x00(\xfc\xef\x0epy2app-test.py\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00)v\x89\xc3D\xd9M\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00I
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x08\x00\x00\xc2\xca\xd9\xb1\x00\x00\x00\x11\x00\x08\x00\x00\xc3E\x11\x8d\x00\x00\x00\x0e\x00\x1e\x00\x0e\x00p\x00y\x002\x00a\x00p\x00p\x00-\x00t\x00e\x00s\x00t\x00.\x00p\x00y\x00\x0f\x00\x1a\x00\x0c\x00M\x00a\x00c\x00i\x00n\x00t\x00o\x00s\x00h\x00
\x00H\x00D\x00\x12\x00\x1aprivate/tmp/py2app-test.py\x00\x13\x00\x01/\x00\xff\xff\x00\x00',
'/private/tmp/py2app-test.py'))
  File "/tmp/py2app-test.app/Contents/Resources/__boot__.py", line 153, in _run
    execfile(path, globals(), globals())
  File "/private/tmp/py2app-test.py", line 7, in ?
    import wx
ImportError: No module named wx
2007-10-24 11:23:57.724 py2app-test[14467] py2app-test Error
2007-10-24 11:23:57.725 py2app-test[14467] py2app-test Error
An unexpected error has occurred during execution of the main script

ImportError: No module named wx

/tmp$ kill %1
[1]+  Terminated              tail -n 0 -f /Library/Logs/Console/$(id
-u)/console.log
/tmp$

And for the sake of clarity:
--- dot_py_sys_path     2007-10-24 11:51:41.000000000 -0400
+++ dot_app_sys_path    2007-10-24 11:51:57.000000000 -0400
@@ -4,7 +4,8 @@
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/UNKNOWN-0.0.0-py2.4.egg',
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/configobj-4.4.0-py2.4.egg',
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app-0.3.6-py2.4.egg',
-       '/Users/rbronosky/Code/python/site-packages',
+       '/private/tmp/py2app-test.app/Contents/Resources',
+       '/tmp/py2app-test.app/Contents/Resources',
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python24.zip',
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4',
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat-darwin',
@@ -12,9 +13,8 @@
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat-mac/lib-scriptpackages',
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-tk',
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload',
+       '/tmp/py2app-test.app/Contents/Resources/lib/python2.4/site-packages.zip',
        '/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages',
-       '/opt/local/lib/python2.4/site-packages',
-       '/opt/local/lib/python2.4/site-packages/Numeric',
-       '/opt/local/lib/python2.4/site-packages/PyObjC',
-       '/opt/local/lib/python2.4/site-packages/wx-2.8-mac-unicode'
+       '/Users/rbronosky/Library/Python/2.4/site-packages',
+       '/private/tmp'
 ]


More information about the Pythonmac-SIG mailing list