尝试使用Python27运行Kivy应用程序时出错:引发异常('SDL2:无法加载图像')

时间:2016-12-31 22:07:50

标签: python python-2.7 sdl kivy

我一直在制作一些Kivy应用程序并且它们可以在Python34中正常工作但由于某些原因突然停止使用Python27,之后在代码中没有任何变化。我一直在寻找一个解决方案,并尝试添加东西到路径,卸载和重新安装gstreamer,更新Python,更新kivy,更新依赖等等,没有解决它!这是我在控制台上获得的输出:

[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 个答案:

答案 0 :(得分:1)

最近,主分支中的依赖关系发生了变化。由于路径上的DLL冲突,很可能会引发异常。

我遇到了zlib1.dll文件与Intel驱动程序的冲突。然而,在Kivy中有一个针对依赖性的修复来防止这种冲突。如果没有PATH share/sdl2/bin中的同名文件,请将相关性更新为最新版本,或检查share/glew/bin中的文件夹。

如果有,请确保在崩溃窗口创建的路径之前放置的Kivy依赖路径。