简体   繁体   中英

Error when trying to run Kivy app with Python27: raise Exception('SDL2: Unable to load image')

I've been making a few Kivy apps and they work fine with Python34 but for some reason the suddenly stopped working with Python27, after nothing had even changed in the code. I've looked all over for a solution, and have tried adding things to the Path, uninstalling and reinstalling gstreamer, updating Python, updating kivy, updating dependences etc. and nothing has solved it! This is the output I get on the console:

[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 at all!

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 138, in __init__
    super(WindowSDL, self).__init__()

  File "C:\Python27\lib\site-packages\kivy\core\window\__init__.py", line 722, in __init__

    self.create_window()

  File "C:\Python27\lib\site-packages\kivy\core\window\window_sdl2.py", line 255, in create_window

    super(WindowSDL, self).create_window()

  File "C:\Python27\lib\site-packages\kivy\core\window\__init__.py", line 897, in create_window

    self.render_context = RenderContext()

  File "kivy\graphics\instructions.pyx", line 756, in kivy.graphics.instructions.RenderContext.__init__ (kivy\graphics\instructions.c:10729)

  File "C:\Python27\lib\site-packages\kivy\core\image\__init__.py", line 512, in __init__

    self.filename = arg

  File "C:\Python27\lib\site-packages\kivy\core\image\__init__.py", line 700, in _set_filename

    mipmap=self._mipmap, nocache=self._nocache)

  File "C:\Python27\lib\site-packages\kivy\core\image\__init__.py", line 430, in load

    im = loader(filename, **kwargs)

  File "C:\Python27\lib\site-packages\kivy\core\image\__init__.py", line 198, in __init__

    self._data = self.load(filename)

  File "C:\Python27\lib\site-packages\kivy\core\image\img_sdl2.py", line 42, in load

    raise Exception('SDL2: Unable to load image')

[CRITICAL          ] [App         ] Unable to get a Window, abort.

Recently there were changes in dependencies as in the master branch. The exception is most likely raised because of a collision of DLLs on your path.

I experienced a collision with zlib1.dll file which belonged to Intel drivers. There was however a fix made for dependencies to prevent such collision in Kivy. Either update the dependencies to the latest ones, or check folders in PATH , if there isn't a same-named file as in share/sdl2/bin , share/glew/bin .

If there is, make sure the path of Kivy dependencies is placed before the path that crashes the Window creation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM