python - ImportError:在处理异常时运行`from pyglet.gl import *`时发生错误:找不到库“GL”
问题描述
当我在 docker 中运行强化任务的 python 代码时,它无法呈现。当我收到导入错误时,我尝试安装 GL,但它仍然给我同样的错误。有没有其他方法可以解决这个问题而不会弄乱包管理器?
错误信息:
/usr/local/lib/python3.7/site-packages/gym/logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Episode 0
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/lbforaging/foraging/rendering.py", line 33, in <module>
from pyglet.gl import *
File "/usr/local/lib/python3.7/site-packages/pyglet/gl/__init__.py", line 95, in <module>
from pyglet.gl.lib import GLException
File "/usr/local/lib/python3.7/site-packages/pyglet/gl/lib.py", line 149, in <module>
from pyglet.gl.lib_glx import link_GL, link_GLU, link_GLX
File "/usr/local/lib/python3.7/site-packages/pyglet/gl/lib_glx.py", line 45, in <module>
gl_lib = pyglet.lib.load_library('GL')
File "/usr/local/lib/python3.7/site-packages/pyglet/lib.py", line 164, in load_library
raise ImportError('Library "%s" not found.' % names[0])
ImportError: Library "GL" not found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "if.py", line 106, in <module>
env.render()
File "/usr/local/lib/python3.7/site-packages/lbforaging/foraging/environment.py", line 501, in render
self._init_render()
File "/usr/local/lib/python3.7/site-packages/lbforaging/foraging/environment.py", line 494, in
_init_render
from .rendering import Viewer
File "/usr/local/lib/python3.7/site-packages/lbforaging/foraging/rendering.py", line 41, in <module>
"""
ImportError:
Error occured while running `from pyglet.gl import *`
HINT: make sure you have OpenGL install. On Ubuntu, you can run 'apt-get install python-opengl'.
If you're running on a server, you may need a virtual frame buffer; something like this should work:
'xvfb-run -s "-screen 0 1400x900x24" python <your_script.py>'
pip3 install GL
表示要求已经满足并给出相同的错误“找不到GL”并pip3 install OpenGL
给出:
ERROR: Could not find a version that satisfies the requirement OpenGL
ERROR: No matching distribution found for OpenGL
解决方案
您需要旧版本的 pyglet;通过 pip 安装它应该可以解决问题:
pip install pyglet==1.5.11
此处进一步讨论:
推荐阅读
- android-studio - Android Studio 模拟器屏幕塌陷
- angular - Angular 应用程序使用 index.php 而不是 index.html
- r - 如何根据 x 轴上的指定点有选择地为绘图的整个区域着色?
- python - Python:如何创建具有动态参数数量的参数网格
- jpos - jpos : 如何打包 DE 55
- sql - 我的 INSERT 语句与 FOREIGN KEY 约束冲突
- c# - C# 等效于 CreateIoCompletionPort
- uwp - 是否可以在机器范围内安装 Microsoft Store 应用程序?
- javascript - 选中复选框时引导数据表保持全部禁用
- .net-core - 带日期时间的 Odata V4