1 问题描述
在 pip install pyrender成功安装后,调用pyrender库时报错:
OSError: (‘GL: cannot open shared object file: No such file or directory’, ‘GL’, None)
ImportError: (‘Unable to load OpenGL library’, ‘GL: cannot open shared object file: No such file or directory’, ‘GL’, None)
报错截图:

2 原因分析
这种问题一般会出现在本机/docker环境中,我这个错误发生在(基本上发生在linux系统中,windows一般都不会出现):
Ubuntu18.04
Python3.9
anaconda base
报错信息聚焦在:No such file or directory', 'GL'。也就是当前环境中缺少GL库文件,是GL库有问题,所以导致pyrender不能正常运行,这也解释了为什么pip install pyrender可以正常安装,但是pyrender却运行不了。
3 解决方法
既然是GL库文件缺失导致的这个问题,那就需要在当前系统中重新安装GL库文件。具体操作流程:
3.1 更新apt
apt-get update
这一步非常重要,一般出现这种问题都是说明当前linux系统存在问题,因此当前的源也有极大概率是坏的,所以一定要确保更新到最新的源再进行下一步。
apt更新过程:

3.2 安装GL库
执行:
apt install libgl1-mesa-glx
3.3 测试是否解决
完成安装后,打开python导入pyrender,检查是否可以正确导入。
如图所示,现在已经可以正确导入pyrender库。

179

被折叠的 条评论
为什么被折叠?



