由于窗口问题,与pyinstaller打包后,Kivy应用程序崩溃 [英] Kivy app crashes after being packaged with pyinstaller due to window issue

查看:116
本文介绍了由于窗口问题,与pyinstaller打包后,Kivy应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Pyinstaller打包我的kivy项目,但它会崩溃并将其吐出

I'm trying to package my kivy project with Pyinstaller but it crashes and spits this out

[CRITICAL          ] [Window      ] Unable to find any valuable Window     provider at all!
sdl2 - Exception: SDL2: Unable to load image
 File "site-packages\kivy\core\__init__.py", line 67, in core_select_lib
 File "site-packages\kivy\core\window\window_sdl2.py", line 138, in __init__
 File "site-packages\kivy\core\window\__init__.py", line 722, in __init__
 File "site-packages\kivy\core\window\window_sdl2.py", line 255, in   
 create_window

 File "site-packages\kivy\core\window\__init__.py", line 897, in create_window
 File "kivy\graphics\instructions.pyx", line 756, in     
 kivy.graphics.instructions.RenderContext.__init__ (kivy\graphics\instructions.c:10729)
 File "site-packages\kivy\core\image\__init__.py", line 512, in __init__
 File "site-packages\kivy\core\image\__init__.py", line 700, in _set_filename
 File "site-packages\kivy\core\image\__init__.py", line 430, in load
 File "site-packages\kivy\core\image\__init__.py", line 198, in __init__
 File "site-packages\kivy\core\image\img_sdl2.py", line 42, in load

[INFO              ] [Audio       ] Providers: audio_sdl2 (audio_ffpyplayer ignored)
[CRITICAL          ] [App         ] Unable to get a Window, abort.
Exception ignored in: 'kivy.properties.dpi2px'
Traceback (most recent call last):
File "site-packages\kivy\utils.py", line 513, in __get__
File "site-packages\kivy\metrics.py", line 175, in dpi
File "site-packages\kivy\base.py", line 126, in ensure_window
SystemExit: 1
[CRITICAL          ] [App         ] Unable to get a Window, abort.
Exception ignored in: 'kivy.properties.dpi2px'
Traceback (most recent call last):
File "site-packages\kivy\utils.py", line 513, in __get__
File "site-packages\kivy\metrics.py", line 175, in dpi
File "site-packages\kivy\base.py", line 126, in ensure_window
SystemExit: 1
[CRITICAL          ] [App         ] Unable to get a Window, abort.

我没有创建自己的规格文件,而是选择通过在命令行中通过向必需参数传递任何建议来做到这一点?

I did not create my own spec file I chose to do it via the command line by passing the required arguments any suggestions?

这是pyinstaller生成的规范文件

This is the spec file generated by pyinstaller

# -*- mode: python -*-

block_cipher = None


a = Analysis(['apv.py'],
         pathex=['C:\\Python34\\Lib\\site-packages\\kivy', 'C:\\Python34', 'C:\\Python34\\Lib', 'C:\\Python34\\Lib\\site-packages', 'C:\\Users\\suroh\\Desktop\\my-python-modules', 'C:\\Python34\\Lib\\site-packages\\kivy\\deps', 'C:\\Python34\\Lib\\site-packages\\kivy\\graphic', 'C:\\Python34\\DLLs', 'C:\\Python34\\libs', 'C:\\Python34\\Scripts', 'C:\\Python34\\share\\sdl2\\bin', 'C:\\Python34\\share\\glew\\bin', 'C:\\Python34\\share', 'C:\\Python34\\Tools', 'C:\\Python34\\Lib\\ctypes', 'C:\\Python34\\Lib\\distutils', 'C:\\Users\\suroh\\Desktop\\Python Projects\\testp\\Beta 01'],
         binaries=None,
         datas=None,
         hiddenimports=[],
         hookspath=[],
         runtime_hooks=[],
         excludes=['pygame'],
         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='apv',
      debug=False,
      strip=False,
      upx=True,
      console=False , icon='LauncherIcon.ico')
coll = COLLECT(exe,
           a.binaries,
           a.zipfiles,
           a.datas,
           strip=False,
           upx=True,
           name='apv')

推荐答案

如果您没有创建规范文件,仍然需要打包

If you didn't create spec file, you still need to package the dependencies which are here in the Collect().

如pyinstaller的 docs :

As it is mentioned in the pyinstaller's docs:

您可以在pyinstaller命令行上提供其他文件.

You can give additional files on the pyinstaller command line.

这意味着您可以 --add-data ,也可以将规范转储到某个地方,然后使用 --specpath . 此处Collect()的基本作用打包东西.

Which means that you could do --add-data or you can dump the spec somewhere and edit it manually with --specpath. Here is what Collect() basically does to package the stuff.

修改: 是的,您肯定错过了部门.看看kivy的规格.

Yup, you're definitely missing the deps. Look at kivy's spec.

如果要使用--add-data,则应检查kivy.deps文件夹和其中的__init__(),因为它们会告诉您要查找的路径.但是,手动编辑规范耗时较少.

If you would go for --add-data, you should check kivy.deps folder and __init__()s in them, because those will tell you what path you are looking for. But editing the spec manually is less time consuming.

这篇关于由于窗口问题,与pyinstaller打包后,Kivy应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆