Kivy SDL2: Unable to load image

2020-08-06 19:03:44,843 MainThread WARNING : Image: Unable to load image <C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\data\glsl\default.png>
2020-08-06 19:03:44,848 MainThread CRITICAL : Window: Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - Exception: SDL2: Unable to load image
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\__init__.py", line 71, in core_select_lib
    cls = cls()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 152, in __init__
    super(WindowSDL, self).__init__()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\__init__.py", line 981, in __init__
    self.create_window()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 312, in create_window
    super(WindowSDL, self).create_window()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\__init__.py", line 1258, in create_window
    self.render_context = RenderContext()
  File "kivy\graphics\instructions.pyx", line 783, in kivy.graphics.instructions.RenderContext.__init__
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\image\__init__.py", line 561, in __init__
    self.filename = arg
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\image\__init__.py", line 756, in _set_filename
    mipmap=self._mipmap, nocache=self._nocache)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\image\__init__.py", line 460, in load
    im = loader(filename, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\image\__init__.py", line 223, in __init__
    self._data = self.load(filename)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\image\img_sdl2.py", line 47, in load
    raise Exception('SDL2: Unable to load image')

这个文件C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\data\glsl\default.png 是存在的

处理办法:在导入kivy模块前添加一下代码

import os 
os.environ['KIVY_IMAGE'] = 'pil,sdl2'

参考:https://github.com/kivy/kivy/issues/4115

posted @ 2020-08-06 21:07  Onsunsl  阅读(938)  评论(0编辑  收藏  举报