ManimGL 与 ManimCE 的区别:3b1b 版和社区版到底装哪个?
"Manim" actually names two active codebases, and picking the wrong one wastes days. ManimGL is Grant Sanderson's personal engine (PyPI: manimgl, import manimlib), optimized for his real-time, interactive 3Blue1Brown workflow with an OpenGL renderer; docs are thinner and APIs shift with his videos. ManimCE (PyPI: manim, import manim) is the community fork of the 2019 codebase, rewritten with Sphinx documentation, a plugin system, unit tests, and stable releases — currently v0.22.x. For learners, tutorial-followers and plugin users, ManimCE is the right default: nearly all Chinese tutorials, Stack Overflow answers and example galleries target it. ManimGL suits you only if you specifically reproduce 3b1b source files or need live coding previews. Key API differences and a migration checklist are included.
一句话结论
学动画、看教程、做项目:装社区版(pip install manim)。只有当你想直接跑 3Blue1Brown 视频的源码、或需要实时交互预览时,才用 ManimGL。本站全部教程基于社区版。
两个版本的来历
Grant Sanderson(3Blue1Brown)2018 年开源了最早的 manim。2019 年社区基于它 fork 出 Manim Community Edition,重写了文档系统、加了插件机制和测试;Grant 本人的仓库后来演进为 ManimGL,继续服务他自己的视频创作。两者同源但已分道扬镳,API 不兼容。
核心对比表
| 维度 | ManimCE(社区版) | ManimGL(3b1b 版) |
|---|---|---|
| 安装 | pip install manim | pip install ManimGL |
| 导入 | from manim import * | from manimlib import * |
| 命令 | manim -pql file.py Scene | manimgl file.py Scene |
| 渲染器 | cairo(默认,稳定)/ opengl | OpenGL 实时渲染 |
| 文档 | Sphinx 完整文档 + 示例库 | 相对简略 |
| 插件生态 | 有插件系统(manim-slides 等) | 无正式插件机制 |
| API 风格 | 稳定,弃用有过渡期 | 随 3b1b 需要自由变动 |
| 交互 | 较弱 | 强(实时拖拽、命令行交互) |
代码层面的典型差异
同一个"写公式"的场景,两边的写法区别:
# ManimCE(社区版)
class Formula(Scene):
def construct(self):
f = MathTex(r"e^{i\pi} + 1 = 0", font_size=72)
self.play(Write(f))
# ManimGL(3b1b 版)
class Formula(Scene):
def construct(self):
f = Tex(r"e^{i\pi} + 1 = 0", font_size=72)
self.play(Write(f))
高频踩坑点:
- 公式类:CE 用
MathTex(纯公式)与Tex(文本模式);GL 只有Tex,数学模式靠转义。 - 颜色常量:两边大部分同名(BLUE/RED…),个别色号值不同,/GL 特有的 CYAN 亮青色系差异明显。
- 坐标轴:CE 的
Axes参数是x_axis_config、y_axis_config;GL 是axis_config加number_line_config。 - 3D:GL 的相机与交互 API 更顺手;CE 用
ThreeDScene的set_camera_orientation/move_camera。
按需求选版本
- 跟中文/英文教程学 → CE。市面上 95% 的教程、问答、示例库针对 CE。
- 复刻 3b1b 某期视频 → 看他的源码是哪个版本写的(仓库 3b1b/videos 早期视频旧版、近年 GL);用 CE 重写也完全可行,见我们的复刻系列。
- 课堂演示、做 slides → CE + manim-slides 插件。
- 实时调参、边写边看 → GL 的交互体验更好。
从 GL 迁移到 CE 的检查清单
Tex数学公式 → 改MathTexaxis_config→x_axis_config/y_axis_config- 布局函数(arrange/next_to)基本同名,个别 buff 默认值不同,微调间距
- 渲染命令改为
manim -pql 文件.py 场景名 - 用官方 CE 文档的示例库核对每个报错
两个版本可以装在同一个机器的不同 venv 里共存,互不干扰,按项目切换环境即可。