简体   繁体   中英

Help building a mac application from python using py2app?

I have a Tkinter app written in python, and I want to make "native" (easy to run) mac and windows executables of it. I've successfully built a windows .exe using py2exe, but the equivalent process with py2app isn't working.

Here's my setup.py:

from setuptools import setup
import sys
MAIN_SCRIPT = "myapp.py" WINDOWS_ICON = "myicon.ico" MAC_ICON = "myicon.icns"
if sys.platform in ("win32", "win64"): # does win64 exist? import py2exe setup( windows=[{ "script":MAIN_SCRIPT, "icon_resources":[(0x0004, WINDOWS_ICON)] }], ) elif sys.platform == "darwin": import py2app setup( app=[MAIN_SCRIPT], # doesn't include the icon yet setup_requires=["py2app"], )

I just cd to my app directory and run python setup.py py2app . The .app appears without errors, but it crashes on launch with "myapp has encountered a fatal error, and will now terminate."

I'm running Snow Leopard, and I've tried this with both the standard Apple Python 2.6 and python25 from MacPorts. I read somewhere that it's better to use a different Python because py2app won't bundle the system version in your app.

EDIT: Here's what the mac console has to say about it:

11/27/10 1:54:44 PM  [0x0-0x80080].org.pythonmac.unspecified.myapp[77495]    dlsym(0x10b120, Py_SetProgramName): symbol not found
11/27/10 1:54:46 PM [0x0-0x80080].org.pythonmac.unspecified.myapp[77495]    0x99274242
11/27/10 1:54:46 PM com.apple.launchd.peruser.501[185]  ([0x0-0x80080].org.pythonmac.unspecified.myapp[77495]) Exited with exit code: 255

Turns out it was a problem with using Snow Leopard. I tried it on a Leopard machine at school and it builds fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM