简体   繁体   中英

Kivy app crashes after packaging with pyinstaller

Here are some of the pointers for the issue I've been facing:

  • Trying to package a example app that comes with Kivy.
  • I am able to run the app normally via command line [kivy main.py]
  • When I try to package the app with Pyinstaller, the spec file is generated, and the app can be packaged, but this is what I see in the warning text file: http://pastebin.com/3D2A9ZLG
  • The app is not able to start after that, and this is the error I see in the console logs: (com.apple.xpc.launchd.oneshot.0x10000028.day2[6584]) Service exited with abnormal code: 1

Kivy Installation

  • Installed Kivy 1.9.0 on Mac OS X Yosemite using the DMG that came with the download. And ran the MakeSymbols script with sudo user.
  • Kivy is currently installed in the Applications folder
  • Pyinstaller 2.0 is being used by downloading the code from their Github repo, and running kivy pyinstaller --windowed --name guide main.py
  • I'm using Python 2.7

Code:

Here's the spec file for the app I tried creating with the example:

# -*- mode: python -*-

from kivy.tools.packaging.pyinstaller_hooks import install_hooks
install_hooks(globals())

a = Analysis(['/Users/karthik/Desktop/SHRINK/kivy/examples/guide/quickstart/main.py'],
             pathex=['/Users/karthik/Desktop/SHRINK/pyinstaller-2.0'],
             hiddenimports=[])
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=1,
          name=os.path.join('build/pyi.darwin/day2', 'day2'),
          debug=False,
          strip=None,
          upx=True,
          console=False )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=False,
               name=os.path.join('dist', 'day2'))
app = BUNDLE(coll,
             name=os.path.join('dist', 'day2.app'))

Any help would be highly appreciated.

I can see a couple of issues, you're using the os library without importing it which should cause some issues and according to here: ( http://kivy.org/docs/guide/packaging-windows.html ) you need to include the path in the COLLECT statement so kivy can find everything.

coll = COLLECT( exe, Tree('../kivy27/examples/demo/touchtracer/'),
           a.binaries, Tree([f for f in os.environ.get('KIVY_SDL2_PATH', '').split(';') if 'bin' in f][0])
           #...
           )

Kivy 1.9.0 also uses SDL2 instead of Pygame so you need to link pyinstaller to that as well. In my experience Kivy is quite tempermental working through Pyinstaller so I recommend attempting to follow the link I posted above.

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