SDL2: Unable to load image error when starting a simple kivy app

2,139 views
Skip to first unread message

Jinlxz Liu

unread,
Sep 3, 2017, 3:47:47 AM9/3/17
to Kivy users support
I'v just installed kivy and want to have a try, I wrote a simple kivy script and tried to run, the app exited with exception "SDL2: Unable to load image" , the code is as follows
import os
import kivy
kivy
.require('1.10.0')
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
   
def build(self):
       
return Label(text='Hello world')
if __name__ == '__main__':
   
MyApp().run()
The output is as follows:
E:\workspace\kivy_test>python basic_test.py
[INFO   ] [Logger      ] Record log in C:\Users\liu\.kivy\logs\kivy_17-09-03_0.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [OSC         ] using <thread> for socket
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <3.3.11672 Compatibility Profile Context>
[INFO   ] [GL          ] OpenGL vendor <ATI Technologies Inc.>
[INFO   ] [GL          ] OpenGL renderer <ATI Mobility Radeon HD 4300 Series>
[INFO   ] [GL          ] OpenGL parsed version: 3, 3
[INFO   ] [GL          ] Shading version <3.30>
[INFO   ] [GL          ] Texture max size <8192>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Shader      ] fragment shader: <Fragment shader was successfully compiled to run on hardware.>
[INFO   ] [Shader      ] vertex shader: <Vertex shader was successfully compiled to run on hardware.>
[INFO   ] [Shader      ] program: <Vertex shader(s) linked, fragment shader(s) linked.>
[WARNING] [Image       ] Unable to load image <C:\Python27\Lib\site-packages\kivy\data\glsl\default.png>
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2
- Exception: SDL2: Unable to load image
 
File "C:\Python27\Lib\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
    cls
= cls()
 
File "C:\Python27\Lib\site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
   
super(WindowSDL, self).__init__()
 
File "C:\Python27\Lib\site-packages\kivy\core\window\__init__.py", line 899, in __init__
   
self.create_window()
 
File "C:\Python27\Lib\site-packages\kivy\core\window\window_sdl2.py", line 291, in create_window
   
super(WindowSDL, self).create_window()
 
File "C:\Python27\Lib\site-packages\kivy\core\window\__init__.py", line 1051, in create_window
   
self.render_context = RenderContext()
 
File "kivy\graphics\instructions.pyx", line 758, in kivy.graphics.instructions.RenderContext.__init__ (kivy\graphics\instructions.c:12580)
 
File "C:\Python27\Lib\site-packages\kivy\core\image\__init__.py", line 538, in __init__
   
self.filename = arg
 
File "C:\Python27\Lib\site-packages\kivy\core\image\__init__.py", line 734, in _set_filename
    mipmap
=self._mipmap, nocache=self._nocache)
 
File "C:\Python27\Lib\site-packages\kivy\core\image\__init__.py", line 435, in load
    im
= loader(filename, **kwargs)
 
File "C:\Python27\Lib\site-packages\kivy\core\image\__init__.py", line 201, in __init__
   
self._data = self.load(filename)
 
File "C:\Python27\Lib\site-packages\kivy\core\image\img_sdl2.py", line 41, in load
   
raise Exception('SDL2: Unable to load image')

[CRITICAL] [App         ] Unable to get a Window, abort.
 
Exception SystemExit: 1 in 'kivy.properties.dpi2px' ignored
[CRITICAL] [App         ] Unable to get a Window, abort.
my computer has the following configuration:
windows 10 32bit
python 2.7.13
Kivy==1.10.0
Kivy-Garden==0.1.4
kivy.deps.glew==0.1.9
kivy.deps.gstreamer==0.1.12
kivy.deps.sdl2==0.1.17

I have uninstalled and reinstalled kivy and added C:\Python27\share\gstreamer\bin, C:\Python27\share\glew\bin, C:\Python27\share\glew\bin to environtment variable path, it didn't work.

can anyone help me with this problem? I searched on google and have not found any helpful solution.






Ivan Acevedo

unread,
Sep 3, 2017, 7:41:00 AM9/3/17
to kivy-...@googlegroups.com
The same mistake has occurred to me.
What you have to do is delete the folder ".buildozer" that is inside the folder of your project
And also (just in case) the folder ".buildozer" that is in the folder "home".

If the error continues to occur, you must do what I said above, and go to buildozer.spec, in the "requirements" section, add the libraries one by one, that is, add one, then compile the application, add the second, compiles and so on.

Jinlxz Liu

unread,
Sep 3, 2017, 8:50:14 AM9/3/17
to kivy-...@googlegroups.com
Hi, my platform is windows 10, I haven't found the .buildozer folder in the project folder and home folder, and I followed your instructions to uninstall all dependencies of kivy, installed each dependency one by one, compiled the app each time when a new dependency was installed, but it didn't work, at last the same error occured. I uninstalled the dependencies including
docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew kivy.deps.gstreamer
installed each module in the order listed above

Jinlxz Liu

unread,
Sep 3, 2017, 10:42:20 AM9/3/17
to Kivy users support
I have solved this problem.
The reason is that there is another zlib1.dll in the dll search path, probably this dll file doesn't contain the functions needed by kivy.
you can simply rename or delete zlib1.dll file in the dll search path, in my case, the file is c:\windows\system32\zlib1.dll, and reboot your computer, kivy app started successfully.

Yunzhao Xing

unread,
Oct 11, 2018, 3:48:39 PM10/11/18
to Kivy users support
Hi Jinlxz,

Thanks so much! Your answer works on my case. Just one more input, it works for the x64 python 3.7.0 but not x86 version of python3.7.0.
Again, thanks so much!
Reply all
Reply to author
Forward
0 new messages