由于窗口问题,使用 pyinstaller 打包 Kivy 应用程序崩溃 [英] Kivy app crashes after being packaged with pyinstaller due to window issue
问题描述
我正在尝试使用 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-packageskivycore\__init__.py", line 67, in core_select_lib
File "site-packageskivycorewindowwindow_sdl2.py", line 138, in __init__
File "site-packageskivycorewindow\__init__.py", line 722, in __init__
File "site-packageskivycorewindowwindow_sdl2.py", line 255, in
create_window
File "site-packageskivycorewindow\__init__.py", line 897, in create_window
File "kivygraphicsinstructions.pyx", line 756, in
kivy.graphics.instructions.RenderContext.__init__ (kivygraphicsinstructions.c:10729)
File "site-packageskivycoreimage\__init__.py", line 512, in __init__
File "site-packageskivycoreimage\__init__.py", line 700, in _set_filename
File "site-packageskivycoreimage\__init__.py", line 430, in load
File "site-packageskivycoreimage\__init__.py", line 198, in __init__
File "site-packageskivycoreimageimg_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-packageskivyutils.py", line 513, in __get__
File "site-packageskivymetrics.py", line 175, in dpi
File "site-packageskivyase.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-packageskivyutils.py", line 513, in __get__
File "site-packageskivymetrics.py", line 175, in dpi
File "site-packageskivyase.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生成的spec文件
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')
推荐答案
如果你没有创建spec文件,你仍然需要打包here 在 Collect()
中.
If you didn't create spec file, you still need to package the dependencies which are here in the Collect()
.
正如 pyinstaller 的 文档:
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__()
s,因为那些会告诉你你正在寻找什么路径.但是手动编辑规范更省时.
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屋!