我试图用Pyinstaller打包我的kivy项目但它崩溃并吐出来
[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.
我没有创建自己的spec文件,我选择通过命令行通过传递所需的参数来做任何建议吗?
这是pyinstaller生成的spec文件
# -*- 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')
答案 0 :(得分:2)
如果您没有创建规范文件,则仍然需要来打包Collect()
中here的依赖项。
正如pyinstaller的docs中提到的那样:
您可以在pyinstaller命令行上提供其他文件。
这意味着您可以执行--add-data
或者您可以在某处转储规范并使用--specpath
手动编辑它。 Here是Collect()
基本上用来打包的东西。
修改强> 是的,你肯定错过了deps。看看kivy的规格。
如果您选择--add-data
,则应检查其中的kivy.deps
文件夹和__init__()
,因为它们会告诉您要查找的路径。但手动编辑规范的时间较少。