M B*_*ank 16 python opengl opengl-es kivy
我决定在Kivy跨平台上做一些编程,并成功地在我的计算机上安装了Kivy.问题是,当我运行我的代码时,我收到此错误:
[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 ] [OSC ] using <thread> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] OpenGL version <b'1.1.0'>
[INFO ] [GL ] OpenGL vendor <b'Microsoft Corporation'>
[INFO ] [GL ] OpenGL renderer <b'GDI Generic'>
[INFO ] [GL ] OpenGL parsed version: 1, 1
[CRITICAL ] [GL ] Minimum required OpenGL version (2.0) NOT found!
OpenGL version detected: 1.1
Version: b'1.1.0'
Vendor: b'Microsoft Corporation'
Renderer: b'GDI Generic'
Try upgrading your graphics drivers and/or your graphics hardware in case of problems.
The application will leave now.
Run Code Online (Sandbox Code Playgroud)
弹出此错误框:

我通过GPU Caps Viewer检查了我的GPU的OpenGL版本,验证了我的OpenGL版本2.1,但是Kivy不知道检测到OpenGL 2.1并且默认使用Microsoft的GDI Generic.我在互联网上做了一些研究,发现解决这个问题的最佳方法是从你的图形卡制造商处更新你的图形卡的驱动程序,但这在我的情况下不起作用.
我更新了我的图形驱动程序(我在64位Windows 8上运行NVIDIA GeForce GT 435M).
我的问题是:有没有办法让Kivy从GDI Generic驱动程序切换到NVIDIA驱动程序?或者其他地方有问题吗?
小智 16
如果您仍然有问题,请尝试以下操作:
import os
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
Run Code Online (Sandbox Code Playgroud)
它对我有用(Windows 10、OpenGL 3.1、Python 3.6)。
576*_*76i 13
在Windows 7专业版32位添加Config.set('graphics', 'multisamples', '0')解决了我的错误.(更新:这也适用于Windows 10.)
import kivy
kivy.require('1.9.1') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.label import Label
# add the following 2 lines to solve OpenGL 2.0 bug
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()
Run Code Online (Sandbox Code Playgroud)
更改后,正确报告OpenGL版本:
[INFO] [GL] GLEW初始化成功
[INFO] [GL] OpenGL版本<2.1.0 - Build 8.15.10.2281>
py3.5 +的角度后端
pip install kivy.deps.angle
set KIVY_GL_BACKEND=angle_sdl2
Run Code Online (Sandbox Code Playgroud)
它完美适用于Windows 10及其针对上述问题的解决方案.多重采样在我的情况下不起作用
小智 6
我使用Python 3.6和Windows 8.1。也可以在Windows 10上使用。
这个解决方案在大多数情况下解决了这个问题:
。
1.右键单击此PC,然后打开“ 属性”。
2.转到高级系统设置。
3.单击环境变量。
4.单击“- ”中的“ 新建用户变量”。
5. 在变量名称中输入KIVY_GL_BACKEND。
6.将angle_sdl2放入Variable value中。
7. 重新启动Python。
这是展示这些步骤的YouTube视频:https : //www.youtube.com/watch?v=ATK9w2AiDeM
| 归档时间: |
|
| 查看次数: |
15434 次 |
| 最近记录: |