Kivy - windows - 根本找不到任何有价值的窗口提供程序

2022-01-15 00:00:00 python kivy windows graphics

问题描述

我从 kivy 开始.这是我正在运行的示例代码.

I am starting with kivy. here is the sample code I am running.

import kivy
from kivy.app import App
from kivy.uix.button import Label
kivy.require('1.9.0')


class HelloApp(App):
    def build(self):
        return Label(text='Hello World!')

if __name__ == "__main__":
    HelloApp().run()

这是我得到的回溯:

[INFO              ] [Logger      ] Record log in C:Usersmonac.kivylogskivy_16-11-23_9.txt
[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
[INFO              ] [Factory     ] 179 symbols loaded
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO              ] [Text        ] Provider: sdl2
[INFO              ] [OSC         ] using <thread> for socket
[INFO              ] [Window      ] Provider: sdl2
[INFO              ] [GL          ] GLEW initialization succeeded
[INFO              ] [GL          ] OpenGL version <b'4.5.0 NVIDIA 373.06'>
[INFO              ] [GL          ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO              ] [GL          ] OpenGL renderer <b'GeForce GTX 960M/PCIe/SSE2'>
[INFO              ] [GL          ] OpenGL parsed version: 4, 5
[INFO              ] [GL          ] Shading version <b'4.50 NVIDIA'>
[INFO              ] [GL          ] Texture max size <16384>
[INFO              ] [GL          ] Texture max units <32>
[WARNING           ] [Image       ] Unable to load image <C:Python34libsite-packageskivydataglsldefault.png>
[CRITICAL          ] [Window      ] Unable to find any valuable Window provider at all!
sdl2 - Exception: SDL2: Unable to load image
  File "C:Python34libsite-packageskivycore\__init__.py", line 67, in core_select_lib
    cls = cls()
  File "C:Python34libsite-packageskivycorewindowwindow_sdl2.py", line 138, in __init__
    super(WindowSDL, self).__init__()
  File "C:Python34libsite-packageskivycorewindow\__init__.py", line 722, in __init__
    self.create_window()
  File "C:Python34libsite-packageskivycorewindowwindow_sdl2.py", line 255, in create_window
    super(WindowSDL, self).create_window()
  File "C:Python34libsite-packageskivycorewindow\__init__.py", line 897, in create_window
    self.render_context = RenderContext()
  File "kivygraphicsinstructions.pyx", line 756, in kivy.graphics.instructions.RenderContext.__init__ (kivygraphicsinstructions.c:10729)
  File "C:Python34libsite-packageskivycoreimage\__init__.py", line 512, in __init__
    self.filename = arg
  File "C:Python34libsite-packageskivycoreimage\__init__.py", line 700, in _set_filename
    mipmap=self._mipmap, nocache=self._nocache)
  File "C:Python34libsite-packageskivycoreimage\__init__.py", line 430, in load
    im = loader(filename, **kwargs)
  File "C:Python34libsite-packageskivycoreimage\__init__.py", line 198, in __init__
    self._data = self.load(filename)
  File "C:Python34libsite-packageskivycoreimageimg_sdl2.py", line 42, in load
    raise Exception('SDL2: Unable to load image')

[CRITICAL          ] [App         ] Unable to get a Window, abort.
 Exception ignored in: 'kivy.properties.dpi2px'
 Traceback (most recent call last):
   File "C:Python34libsite-packageskivyutils.py", line 513, in __get__
     retval = self.func(inst)
   File "C:Python34libsite-packageskivymetrics.py", line 175, in dpi
     EventLoop.ensure_window()
   File "C:Python34libsite-packageskivyase.py", line 126, in ensure_window
     sys.exit(1)
 SystemExit: 1
[CRITICAL          ] [App         ] Unable to get a Window, abort.

我在 Windows 10 64 位上运行.我已经安装了除了 gstreamer 之外的所有依赖项,目前我不需要.

I am running on windows 10 64bits. I have installed all the dependencies except gstreamer which I won't need at the moment.

我也不确定为什么会收到此错误:

I am also not sure why I am getting this error:

[WARNING           ] [Image       ] Unable to load image <C:Python34libsite-packageskivydataglsldefault.png>

文件存在,我以管理员身份运行代码以避免访问权限问题.

The file exists and I am running my code as admin to avoid access rights problems.

谢谢.


解决方案

您必须安装 Kivy 的依赖项.

You have to install the dependencies for Kivy.

按照此处

python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew

会做你需要的.

相关文章