Kivy 在从 windows 服务打开时抛出 Open GL 错误

Kivy throws Open GL error while opening from a windows service

我试图从 Windows 服务中打开一个使用 pyinstaller 捆绑的 Kivy 应用程序,但它无法打开,抛出

OpenGL Version detected : 1.1

代码:

[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "D:\PythonVENV\mist-app\dist\app\kivy\__init__.pyc"
[INFO   ] [Python      ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "D:\PythonVENV\mist-app\dist\app\app.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] No framebuffers extension is supported
[INFO   ] [GL          ] Backend used <glew>
[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.

但问题是,我的 GPU 运行的是 open gl 4.6

我平时执行的时候:

[INFO   ] [Logger      ] Record log in C:\Users\wasim\.kivy\logs\kivy_20-04-11_61.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.1.10
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.1.12
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "D:\PythonVENV\mist-app\venv\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "D:\PythonVENV\mist-app\venv\Scripts\python.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.6.0 NVIDIA 445.75'>
[INFO   ] [GL          ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO   ] [GL          ] OpenGL renderer <b'GeForce GTX 1060 3GB/PCIe/SSE2'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 6
[INFO   ] [GL          ] Shading version <b'4.60 NVIDIA'>
[INFO   ] [GL          ] Texture max size <32768>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [KivyMD      ] v0.104.0
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [GL          ] NPOT texture support is available
[INFO   ] [Base        ] Start application main loop

我看到很多人抱怨它,但事实是,该应用程序在 运行 正常时按预期运行(没有服务打开它/独立)。

我看到一些问题提到要更改为 angle_sdl2,但它抛出另一个错误 "A valuable windows provider was not found"。我发现它使用 GL 3.2 而不是 4.6

仅打开 sdl 时出现同样的错误。

我终于解决了!

@inclement 你是对的!确实 运行在不同的环境中工作,改变环境并不能弥补工作。

服务 运行 在完全不同的环境中,并且对已登录用户的桌面界面的访问受到限制。

我试着在这里详细解释一下:Pystray icon available when running as a service

对我有用!