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

痞子三分冷 提交于 2019-12-12 03:57:47

问题


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.

回答1:


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.



来源:https://stackoverflow.com/questions/41412020/error-when-trying-to-run-kivy-app-with-python27-raise-exceptionsdl2-unable-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!