MACOS Python安装manim遇到Unable to load OpenGL library

1. 系统

  • macOS Big Sur 11.3.1

2.遇到问题

安装完manim后
在命令行执行manimgl遇到

ImportError: ('Unable to load OpenGL library', 'dlopen(OpenGL, 10): image not found', 'OpenGL', None)

3.解决方法

参考Unable to load/find OpenGL on MacOS #1372

asierralozano commented on 27 Oct 2020
It looks like the issue is getting a fix python/cpython#21241
In the meantime, you can fix this issue by editing PyOpenGL file OpenGL/platform/ctypesloader.py, and changing the line

fullName = util.find_library( name )

to

fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL'

1.首先找到名为ctypesloader.py的文件,我的路径是/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/OpenGL/platform/ctypesloader.py,仅供参考

如果上述路径找不到的话,试试find / -name ctypesloader.py.这是一个全局搜索的指令,目的是遍历所有文件夹寻找文件

2.在79行左右的位置,找到fullName = util.find_library( name ),修改成fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL',如下图所示
MACOS Python安装manim遇到Unable to load OpenGL library_第1张图片
**需要注意的是:**你的系统里只有/System/Library/Frameworks/OpenGL.framework这个路径,而该路径下是没有OpenGL的,但是/System/Library/Frameworks/OpenGL.framework/OpenGL依旧其效果,这是因为

DanielAmmar commented on 29 Nov 2020
You don’t actually need the binary there, just change the fullName variable as suggested.

现在去命令行直接执行manimgl,应该会弹出窗口
MACOS Python安装manim遇到Unable to load OpenGL library_第2张图片

现在去example_scenes.py所在目录下执行manimgl example_scenes.py OpeningManimExample,会如下图所示
MACOS Python安装manim遇到Unable to load OpenGL library_第3张图片

enjoy it

你可能感兴趣的:(改bug)