尝试使用Python27运行Kivy应用程序时出错:引发异常('SDL2:无法加载图像') [英] Error when trying to run Kivy app with Python27: raise Exception('SDL2: Unable to load image')

查看:455
本文介绍了尝试使用Python27运行Kivy应用程序时出错:引发异常('SDL2:无法加载图像')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一些Kivy应用程序,它们可以在Python34上正常工作,但是由于某些原因,即使代码没有任何变化,突然停止使用Python27.我到处都在寻找解决方案,并尝试将内容添加到Path,卸载和重新安装gstreamer,更新Python,更新kivy,更新依赖项等,但没有任何解决方案!这是我在控制台上得到的输出:

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.

推荐答案

最近,依赖关系发生了变化,如master分支一样.该异常很可能是由于您的路径上的DLL冲突引起的.

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.

我遇到了属于Intel驱动程序的zlib1.dll文件的冲突.但是,对依赖项进行了修复,以防止在Kivy中发生此类冲突.将依赖关系更新为最新的依赖关系,或者检查PATH中的文件夹(如果没有与share/sdl2/binshare/glew/bin中相同的文件).

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.

如果存在,请确保将Kivy依赖项的路径放置在 导致Window创建失败的路径之前.

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

这篇关于尝试使用Python27运行Kivy应用程序时出错:引发异常('SDL2:无法加载图像')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆