SDL2错误:“无法加载图像< default.png>".使用pyinstaller冻结kivy应用程序时 [英] SDL2 Error: "Unable to load image <default.png>" when freezing kivy application using pyinstaller
问题描述
我无法使用pyinstaller生成可运行的exe(应用程序的名称为settings_gui).
I'm unable to produce a working exe with pyinstaller (the name of the app is settings_gui).
运行时错误:( 完整日志)
[WARNING ] [Image ] Unable to load image <<project_path>\dist\SETTIN~1\kivy_install\data\glsl\default.png>
[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_wind
ow
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
[CRITICAL ] [App ] Unable to get a Window, abort.
Exception SystemExit: 1 in 'kivy.properties.dpi2px' ignored
[INFO ] [Text ] Provider: sdl2
Traceback (most recent call last):
File "settings_gui.py", line 26, in <module>
AttributeError: 'NoneType' object has no attribute 'clearcolor'
Failed to execute script settings_gui
出了什么问题?我检查了<project_path>/dist/settings_gui/kivy_install/data/glsl/default.png
,它在那里.我发现路径为SETTING~1
很奇怪,这正常吗?我见过此线程,它建议通过_MEIPASS
重定向资源,但是这无济于事-可能是预期的,因为我不是以单文件模式构建应用程序.
What is going wrong? I checked <project_path>/dist/settings_gui/kivy_install/data/glsl/default.png
, it's there. I find it weird however that the path is SETTING~1
, is that normal? I've seen this thread which recommends to redirect the resources through _MEIPASS
, but this doesn't help - expectedly, since I'm not building my app in one-file-mode.
任何有关如何解决此问题的技巧都将受到赞赏.
Any tip on how to troubleshoot this is appreciated.
修改:
更多信息:
- 没有pyinstaller,该应用程序运行得很好-除了关闭或以其他方式停止该应用程序外;当我这样做时,python崩溃了.
- 构建应用程序时,会打开一个奇异的窗口,并立即崩溃.我总是关闭它,然后继续构建过程.
- 我的.spec文件
- 构建日志
- Without pyinstaller, the app runs perfectly fine - except for when I close it or stop it otherwise; when I do that, python crashes.
- When I build my app, a kivy window opens and crashes immediately. I always close it and the build process continues.
- My .spec file
- Logs of the build
推荐答案
我设法通过复制文件来解决此问题
I managed to fix the issue by copying file
From: [Python]\share\sdl2\bin\libpng16-16.dll
To: [Dist]\<projectName>\libpng16-16.dll
已经有一个文件实例,但是我替换为该文件的实例大约大了20kb(从198kb到213kb).
There was an instance of the file already there but the one I replaced it with was about 20kb larger (from 198kb to 213kb).
重要的是我的应用程序现在可以正常工作了,而我没有做任何其他更改.
The important part is that my app works now and I didn't change anything else.
这篇关于SDL2错误:“无法加载图像< default.png>".使用pyinstaller冻结kivy应用程序时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!