Issues

Issue #54 wontfix

PyObjc 2.3 virtualenv --alias setup causes an issue with python 2.7

AcclivityNYC
created an issue
hi, everything works ok when I don't use --alias and I'm using the embedded python framwork. @executable_path/../Frameworks/Python.framework/Versions/2.6/Python But in Debug mode I'm running in this issue because I'm using --alias and the local python framework: /Library/Python/2.7/site-packages/ is now being added to the path because of (http://bugs.python.org/issue4865 ) and causes: ImportError: Bad magic number in /Library/Python/2.7/site-packages/PyObjCTools/__init__.pyc this the wrong PyObjCTools. marc Longer version: Trying upgrading my project from python 2.6 to 2.7.4 Environment: • Running 10.7.4 • Xcode 3.2.6 • created a virtual_env • installed in the virtualenv pyobjc==2.3 • using ~/dev virtualenv --python=python2.7 --no-site-packages checkout4_env cd checkout4_env source bin/activate (installed py2app 0.8 from source) easy_install pyobjc-core==2.3 easy_install pyobjc==2.3 After all this installation, in xcode 3.2.6 I build in debug mode python setup.py py2app --alias --dist-dir ${TARGET_BUILD_DIR} When I run the app now I have the following error: File "/Users/marcvanolmen/dev/checkout4_env/Checkout/build/Debug/Checkout.app/Contents/Resources/Checkout.plugin/Contents/Resources/__boot__.py", line 137, in <module> _run() File "/Users/marcvanolmen/dev/checkout4_env/Checkout/build/Debug/Checkout.app/Contents/Resources/Checkout.plugin/Contents/Resources/__boot__.py", line 131, in _run exec(compile(source, script, 'exec'), globals(), globals()) File "/Users/marcvanolmen/dev/checkout4_env/Checkout/app/checkout.py", line 12, in <module> from PyObjCTools import AppHelper ImportError: Bad magic number in /Library/Python/2.7/site-packages/PyObjCTools/__init__.pyc 2013-05-09 16:07:15.910 Checkout[52789:1d03] Checkout has encountered a fatal error, and will now terminate. 2013-05-09 16:07:15.911 Checkout[52789:1d03] An uncaught exception was raised during execution of the main script: ImportError: Bad magic number in /Library/Python/2.7/site-packages/PyObjCTools/__init__.pyc This may mean that an unexpected error has occurred, or that you do not have all of the dependencies for this bundle. The reason why this is happening is that in Python 2.7 they added /Library/Python/2.7/site-packages/ to the search paths: And it is picking up the older PyObjCTools first http://bugs.python.org/issue4865 checkout sys.path ['/Users/marcvanolmen/dev/checkout4_env/Checkout/app', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/macholib-1.5.1-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/altgraph-0.11-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/modulegraph-0.11-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/py2app-0.8-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/workerpool-0.9.2-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyExcelerator-0.6.4.1-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pysqlite-2.6.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/Reverend-0.4-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_ServiceManagement-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_ServerNotification-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_CoreLocation-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_AppleScriptObjC-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_ScriptingBridge-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_QTKit-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_PubSub-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_InterfaceBuilderKit-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_InstantMessage-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_InputMethodKit-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_DictionaryServices-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_Collaboration-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_CalendarStore-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_XgridFoundation-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_WebKit-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/si Debugger stopped. Program exited with status value:1.te-packages/FormEncode-1.2.6-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/SQLObject-1.4.0b1dev_r4593-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/Markdown-2.3.1-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/Cheetah-2.4.4-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/simplejson-3.3.0-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_core-2.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_SystemConfiguration-2.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_SyncServices-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_SearchKit-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_ScreenSaver-2.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_Quartz-2.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_PreferencePanes-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_Message-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_LaunchServices-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_LatentSemanticMapping-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_InstallerPlugins-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_FSEvents-2.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_ExceptionHandling-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_CoreText-2.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_CoreData-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_Cocoa-2.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_CFNetwork-2.3-py2.7-macosx-10.6-intel.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_Automator-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_AppleScriptKit-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/pyobjc_framework_AddressBook-2.3-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/chardet-2.1.1-py2.7.egg', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/PIL', '/Users/marcvanolmen/dev/checkout4_env/lib/python2.7/site-packages/SQLAlchemy-0.4.8-py2.6.egg'] sys.exec_prefix /Library/Frameworks/Python.framework/Versions/2.7 sys.executable /Library/Frameworks/Python.framework/Versions/2.7/bin/python sys.prefix /Library/Frameworks/Python.framework/Versions/2.7

Comments (5)

  1. Ronald Oussoren repo owner

    This might be a bug in py2app, if I understand you correctly the alias build picks up PyObjC from /Library/Python instead of {sys.prefix}/.../site-packages, while you do get the one from site-packages with a non-alias build (or from the command-line).

  2. AcclivityNYC reporter

    Correct,

    When the app starts up and the first thing it does is trying to import:

    from PyObjCTools import AppHelper

    and because of sys.path order it loads the wrong one.

    Also my app is running in 32-bit mode.

  3. AcclivityNYC reporter

    Workaround

    by doing:

    import sys
    
    if ('/Library/Python/2.7/site-packages' in sys.path):
        sys.path.remove('/Library/Python/2.7/site-packages')
    
    from PyObjCTools import AppHelper
    

    and that worked.

  4. Ronald Oussoren repo owner

    There's nothing I can do about this, the sys.path contents seem to be broken with this configuration.

    I'd stop using Apple's python myself to regain full control about what is installed.

  5. Log in to comment