简体   繁体   English

尝试编译后,Python / Kivy应用程序将无法启动

[英]After attempted compile, Python/Kivy application won't launch

I have created a program that I'm attempting to compile, but after the compiling has finished and I attempt to launch the application from the .exe inside the /dist/ directory, it creates a command prompt window, opens the application window for a brief moment, then closes. 我创建了一个尝试编译的程序,但是编译完成后,我尝试从/ dist /目录中的.exe启动应用程序,它创建了一个命令提示符窗口,打开了一个片刻,然后关闭。

I have followed the Kivy procedure in adding the proper imports, as well as adding the requisite directories into the COLLECT area of the spec. 我已经按照Kivy程序添加了正确的导入,并将必需的目录添加到了规范的COLLECT区域。 I attempted to add the pyinstaller hooks import to the top, as some had recommended on various pages, but to no avail. 我试图将pyinstaller钩子导入添加到顶部,就像某些人在各个页面上所建议的那样,但无济于事。

The application launches normally during testing via the command "python main.py", so I'm quite befuddled as to why it doesn't launch after compiling. 该应用程序可以在测试过程中通过“ python main.py”命令正常启动,因此我对为什么编译后无法启动该应用感到困惑。

The spec: 规格:

# -*- mode: python -*-
from kivy.deps import sdl2, glew

block_cipher = None


a = Analysis(['..\\main.py'],
             pathex=['C:\\python programs\\Escape Room Program\\compiled'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             **get_deps_all())
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='EskapAid',
          debug=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe, Tree('..\\compiled'),
               a.binaries,
               a.zipfiles,
               a.datas, 
               Tree('..\\img\\', 'img'),
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               name='EskapAid')

I don't mind providing any additional information as necessary, including what other steps I may have taken, but at the moment, I'm pretty stumped as to why it's not launching correctly. 我不介意在必要时提供任何其他信息,包括我可能已采取的其他其他步骤,但是目前,我很困惑为什么它无法正确启动。

Try running the application from a console so that you can view the error messages associated with the failed launch; 尝试从控制台运行应用程序,以便您可以查看与失败的启动相关的错误消息。 if you click the .exe to open it, the console will disappear as soon as the application closes, which makes it difficult to see these errors. 如果单击.exe打开它,则控制台将在应用程序关闭时消失,这使得很难看到这些错误。 Most likely, you will see that the application failed to launch because it is missing packages, which you can add to the .spec file under the hiddenimports list. 您很可能会看到应用程序启动失败,因为它缺少软件包,可以将其添加到隐藏导入列表下的.spec文件中。 Check out this post for a description of why this might be necessary. 请查看此帖子 ,以了解可能需要这样做的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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