这是众所周知的,很常见的问题。我尝试了所有找到的解决方案,但没有成功。我正在尝试使用kivy制作简单的python应用程序。运行下面的代码后,我得到了很多错误。代码:
import kivy
kivy.require('1.9.1')
import os
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
from kivy.app import App
from kivy.uix.label import Label
from kivy import Config
Config.set('graphics', 'multisamples', '0')
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
运行代码后:
[INFO ] [Logger ] Record log in C:\Users\Patryk\.kivy\logs\kivy_19-01-18_0.txt
[INFO ] [Kivy ] v1.10.1
[INFO ] [Python ] v3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[INFO ] [Window ] Activate GLES2/ANGLE context
[CRITICAL] [Window ] Unable to find any valuable Window provider.
sdl2 - RuntimeError: b'Could not initialize EGL'
File "C:\Python\lib\site-packages\kivy\core\__init__.py", line 67, in core_select_lib
cls = cls()
File "C:\Python\lib\site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
super(WindowSDL, self).__init__()
File "C:\Python\lib\site-packages\kivy\core\window\__init__.py", line 968, in __init__
self.create_window()
File "C:\Python\lib\site-packages\kivy\core\window\window_sdl2.py", line 272, in create_window
self.fullscreen, resizable, state)
File "kivy\core\window\_window_sdl2.pyx", line 209, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
File "kivy\core\window\_window_sdl2.pyx", line 66, in kivy.core.window._window_sdl2._WindowSDL2Storage.die
[CRITICAL] [App ] Unable to get a Window, abort.
PATH和PYTHONPATHS包含:
C:\Windows\System32;
C:\Python;
C:\Python\DLLs;
C:\Python\Lib;
C:\Python\Scripts;
C:\Python\share\sdl2;
C:\Python\share\glew
在我开始调查之前,我已经看到了:
我尝试过很少的口译员。 Python 3.5.2、3.6.1和3.7.2。错误是一样的。有任何想法吗?
已安装的库列表:
Kivy 1.10.1 1.10.1
Kivy-Garden 0.1.4
Kivy-examples 1.10.1 1.10.1
Pygments 2.3.1 2.3.1
certifi 2018.11.29 2018.11.29
chardet 3.0.4 3.0.4
docutils 0.14 0.14
idna 2.8 2.8
kivy.deps.angle 0.1.7 0.1.7
kivy.deps.glew 0.1.10 0.1.10
kivy.deps.gstreamer 0.1.13 0.1.13
kivy.deps.sdl2 0.1.18 0.1.18
pip 18.1 18.1
pypiwin32 223 223
python-firebase 1.2 1.2
pywin32 224 224
requests 2.21.0 2.21.0
setuptools 40.6.3 40.6.3
urllib3 1.24.1 1.24.1
wheel 0.32.3 0.32.3