How do I use py2app with Anaconda python?

后端 未结 1 1118
無奈伤痛
無奈伤痛 2021-01-03 07:12

I am using Python 3 from the Anaconda distribution, and trying to convert a simple python program into an OS X app (running on El Capitan). Following the instructions in the

相关标签:
1条回答
  • 2021-01-03 08:11

    The suggestion by @l'L'l allowed me to identify the problem: While there were no errors when I generated my app in "alias mode" (using symlinks to the environment instead of copying binaries), building the app without alias mode flushed out the error: py2app looks for the libpython DLL under the non-existent name /Applications/anaconda/lib/libpython3.4.dylib.

    A quick check showed that Anaconda provides this DLL under a slightly different name: libpython3.4m.dylib. While patching dist/my-script.app/Contents/Info.plist fixes the problem, the right solution is to edit setup.py so that future builds will work correctly. With the help of the py2app documentation, I put together the following (partial contents of setup.py shown):

    OPTIONS = {'argv_emulation': True,
               'plist': {
                   'PyRuntimeLocations': [
                    '@executable_path/../Frameworks/libpython3.4m.dylib',
                    '/Applications/anaconda/lib/libpython3.4m.dylib'
                   ]
               }}
    
    setup(
        app=APP,
        data_files=DATA_FILES,
        options={'py2app': OPTIONS},
        setup_requires=['py2app'],
    )
    

    The paths come from the generated Info.plist; I only modified the absolute path, reasoning that if I ever provide a local DLL at the relative path, it will have the default name.

    0 讨论(0)
提交回复
热议问题