使用PyIns创建后,无法从/应用程序运行我的应用程序

2024-10-03 13:26:54 发布

您现在位置:Python中文网/ 问答频道 /正文

打开DMG并将mom.app拖到应用程序后,应用程序会短暂启动并立即关闭(崩溃)

但是,如果我打开包并导航到目录 使用所有打包的内容并双击创建的二进制mom,它就可以正确地启动游戏: 右键单击|显示包内容|

What EXACTLY is the working directory of an installed app in /Applications/<your app>  is it /Applications/<your app> ? 
I tried setting to /Applications/<your app>/Contents and that did not seem to work.  May I do not have a pathing problem, 
but I just get a momentary flash and then it closes down.

下面是PyInstaller使用的规范文件,但是我认为这个问题并不取决于规范文件中的内容:

# -*- mode: python -*-

#                *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins + gstreamer.dep_bins)],
# from kivy.deps import sdl2, glew

# from kivy.deps import sdl2, glew, gstreamer
from kivy.core.audio import SoundLoader

block_cipher = None
from kivy.tools.packaging.pyinstaller_hooks import get_deps_all, hookspath, runtime_hooks
from kivy.tools.packaging.pyinstaller_hooks import get_hooks

added_files = [
         ( '/Users/erikbethke/Desktop/SMS/MarsSim/assets', 'assets' ),
         ( '/Users/erikbethke/Desktop/SMS/MarsSim/simObject/resourceBar.kv', 'simObject' ),
         ( '/Users/erikbethke/Desktop/SMS/MarsSim/views/fileOperations.kv', 'views' ),
         ( '/Users/erikbethke/Desktop/SMS/MarsSim/views/marsDialog.kv', 'views' ),
         ]

a = Analysis(['/Users/erikbethke/Desktop/SMS/MarsSim/marsMain.py'],
             pathex=['/Users/erikbethke/Desktop/SMS/dist'],
             binaries=[],
             datas=added_files,
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=['_tkinter', 'Tkinter', 'enchant', 'twisted'],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='mom',
          debug=False,
          strip=False,
          icon='/Users/erikbethke/Desktop/SMS/MarsSim/logo.icns',
          upx=True,
          console=True )
coll = COLLECT(exe, Tree('/Users/erikbethke/Desktop/SMS/MarsSim/assets'),
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='mom')
app = BUNDLE(coll,
             name='mom.app',
             icon='/Users/erikbethke/Desktop/SMS/MarsSim/logo.icns',
             bundle_identifier=None)

Tags: fromimportfalsetrueappsmsusersviews