Kivy 错误:[CRITICAL] [App] 无法获取窗口,中止
问题描述
我看到的针对此 Kivy 错误的所有解决方案均不适用于我.现在已经有两个多星期了,但我所有的努力都是徒劳的.我使用 python 3.6.4、kivy 1.10.1、pycharm 作为我的 IDE 和 Windows 10.这是错误代码和代码本身:
All the solutions that am seeing for this Kivy error does not work for me. It has been more tha 2 weeks now yet all my efforts are in vain. Am using python 3.6.4, kivy 1.10.1, pycharm as my IDE and Windows 10. here is the error code and the code itself:
代码:
from kivy.core.window import Window
import os
os.environ['KIVY_GL_BACKEND'] = 'angel_sdl2'
from kivy.app import App
from kivy.uix.button import Button
# from kivy import Config
# Config.set('graphics', 'multisamples', '0')
class MyApp(App):
def build(self):
return Button(text='Hello world')
if __name__ == '__main__':
MyApp().run()
错误:
enter code here"C:Program FilesPython36-32python.exe"
"C:/Users/Sabinus O Ofoleta/Desktop/python/tested.py"
[INFO ] [Logger ] Record log in C:UsersSabinus O Ofoleta.kivylogskivy_19-02-21_4.txt
[INFO ] [Kivy ] v1.10.1
[INFO ] [Python ] v3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 12:45:02) [MSC v.1900 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:Program FilesPython36-32Libsite-packages kivycore\__init__.py", line 67, in core_select_lib
cls = cls()
File "C:Program FilesPython36-32Libsite-packages kivycorewindowwindow_sdl2.py", line 140, in __init__
super(WindowSDL, self).__init__()
File "C:Program FilesPython36-32Libsite-packageskivycorewindow\__init__.py", line 968, in __init__
self.create_window()
File "C:Program FilesPython36-32Libsite-packageskivycorewindowwindow_sdl2.py", line 272, in create_window
self.fullscreen,resizable , state)
File "kivycorewindow\_window_sdl2.pyx", line 209, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
File "kivycorewindow\_window_sdl2.pyx", line 66, in kivy.core.window._window_sdl2._WindowSDL2Storage.die
[CRITICAL] [App ] Unable to get a Window, abort.
Process finished with exit code 1
我的电脑使用的是 opengl 1.1,因为其他版本不兼容,所以我决定使用angel_sdl2".谢谢
My computer is using opengl 1.1 because other versions are not compatible so I dicided to use 'angel_sdl2'. Thanks
解决方案
在 Intel GMA 965 和 Win10 的笔记本电脑上出现同样的问题
Same issue on a laptop with Intel GMA 965 and Win10
原因:显卡驱动过时,没有新版本.
The reason: graphics driver is outdated, no new versions.
解决方案(对我有用):
1) 通过 pal1000 https://github.com/pal1000/save 应用工具-legacy-intel-graphics
1) Apply tool by pal1000 https://github.com/pal1000/save-legacy-intel-graphics
(更多信息请访问 https://community.khronos.org/t/i-have-opengl-3-1-but-kivy-says-that-i-have-only-1-1/103980/6)
2) 安装依赖,比如
python -m pip install --ignore-installed kivy.deps.sdl2 kivy.deps.glew
(并将系统变量KIVY_GL_BACKEND"设置为glew",或者不设置 - 这是默认值;顺便说一句,安装 kivy.deps.angle 并设置angle_sdl2"没有帮助我在这种情况下)
(and set system variable "KIVY_GL_BACKEND" to "glew", or don't set - this is default value; btw installing kivy.deps.angle and setting "angle_sdl2" don't help me in this case)
3) 在python代码前添加:
3) Add this before python code:
from kivy import Config
Config.set('graphics', 'multisamples', '0')
(来自 Kivy 未检测到 OpenGL 2.0)
相关文章