Py2app with native Python 2.6

2019-08-28 10:50发布

I have a python application primarily dependent on matplotlib, tkinter, numpy and scipy I have been distributing for multiple operating systems. I build these on top of the python.org version of python 2.6. For mac, I have had good success in the past with py2app and pyinstaller to build standalone versions of my application. Recently, however, I have included functions that require patsy, pandas and igraph and have had to move to the mac distributed version of python 2.6 in order to get igraph to work. All works fine in building a py2app version of my software on the Mac for my OS (10.6) but when I run on 10.8 I encountered the following error:

Traceback (most recent call last):
 File "UI.pyc", line 603 createHeatMap
 File "clustering.pyc", line 31, in <module>
 File "mpl_toolkits/__init__.pyc", line 2, in <module>
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 698, in <module>
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 701, in Environment
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 96, in get_supported_platform
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 222, in get_build_platform
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/util.py", line 98, in get_platform
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 537, in get_config_vars
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 405, in _init_posix
DistutilsPlatformError: invalid Python installation: unable to open /user/include/python2.6/pyconfig.h (No such file or directory)

This is fixed by saving the file pyconfig.h to the designated location on the destination machine (not present in 10.8 but present in 10.6), which allows my application to work fine. In my py2app pacakge directory, under "Contents/Resources" there is a sym-link to the directory "include" which points to: /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h. If I include the pyconfig.h file as an addition resource in my py2app setup file, it also includes it in the package, but it still is not recognized.

Can anyone suggest a good work around for this that doesn't require me to use the python.org version of python (I've had horrible luck getting igraph to work with this).

Thanks...

1条回答
Luminary・发光体
2楼-- · 2019-08-28 11:35

This is a known issue in py2app, see https://bitbucket.org/ronaldoussoren/py2app/issue/36/py2app-fails-to-build-a-working-executable. The pyconfig.h file is only present on machines where the developer tools are installed, which is why I haven't noticed the problem myself.

The easiest workaround is probably to replace the pyconfig.h symlink by a copy of the file after creating the app bundle.

查看更多
登录 后发表回答