Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
946 views
in Technique[技术] by (71.8m points)

python - SDL2 Error: "Unable to load image <default.png>" when freezing kivy application using pyinstaller

I'm unable to produce a working exe with pyinstaller (the name of the app is settings_gui).

Runtime error: (Full log)

[WARNING           ] [Image       ] Unable to load image <<project_path>distSETTIN~1kivy_installdataglsldefault.png>
[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_wind
ow
  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

[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

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.

Edit:

More info:

  • 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I managed to fix the issue by copying file

From: [Python]sharesdl2inlibpng16-16.dll
To:   [Dist]<projectName>libpng16-16.dll

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...