Manim 安装教程:Windows / macOS / Linux 全平台环境搭建(2026 最新)
This guide walks through installing Manim Community Edition (the `manim` PyPI package, v0.22.x as of late 2026) on Windows, macOS and Linux. Manim is a Python library, so you need Python 3.9-3.12 first. Two system dependencies matter: FFmpeg for encoding video output, and a LaTeX distribution (MiKTeX/TeX Live/MacTeX) only if you render mathematical formulas with MathTex. Plain Text, shapes and plots work without LaTeX. The recommended path is a virtual environment plus `pip install manim`, then verify with a minimal scene rendered at low quality (`manim -pql`). If you hit errors like missing latex, ffmpeg not found or pycairo build failures, jump to our dedicated troubleshooting guide.
安装前的两个决定
开始之前先确认两件事,能少走 90% 的弯路:
- 装哪个发行版:本站教程全部基于 Manim Community Edition(PyPI 包名
manim)。它与 Grant Sanderson 自用的 ManimGL 是两个分支,区别见《ManimGL 与 ManimCE 的区别》。 - Python 版本:选 3.9 ~ 3.12。过新的大版本(如 3.13)经常还没适配二进制依赖,是安装失败的头号原因。
三步装好核心库
所有平台通用流程:建虚拟环境 → pip 安装 → 装系统依赖。虚拟环境强烈建议,Manim 依赖较多(numpy、cairo、pango、moviepy),直装全局环境迟早污染。
# Windows (PowerShell)
python -m venv manim-env
manim-env\Scriptsctivate
pip install manim
# macOS / Linux
python3 -m venv manim-env
source manim-env/bin/activate
pip install manim
安装完成后先验证库本身:
manim --version
# 输出 Manim Community Edition v0.22.x 即成功
系统依赖一:FFmpeg(必须)
Manim 渲染动画最终要靠 FFmpeg 合成视频,没有它会在渲染时报 ffmpeg not found。
- Windows:
winget install ffmpeg(或从 gyan.dev 下载压缩包解压后把 bin 目录加入 PATH)。 - macOS:
brew install ffmpeg - Debian / Ubuntu:
sudo apt install ffmpeg
验证:ffmpeg -version 能输出版本号即可。
系统依赖二:LaTeX(可选,渲染公式才需要)
只有用到 MathTex(数学公式)时才需要 LaTeX。Text、图形、函数图像都不依赖它。
- Windows:安装 MiKTeX,首次渲染公式时会提示自动装缺的宏包,点允许即可。
- macOS:
brew install --cask mactex-no-gui - Linux:
sudo apt install texlive texlive-latex-extra texlive-fonts-recommended texlive-latex-recommended
第一个验证场景
新建 hello.py:
from manim import *
class HelloManim(Scene):
def construct(self):
text = Text("Hello Manim", font_size=48, gradient=(BLUE, PURPLE))
self.play(Write(text), run_time=2)
self.play(text.animate.scale(1.5), run_time=1)
self.wait()
渲染并预览:
manim -pql hello.py HelloManim
-p 渲染完自动播放,-ql 是 480p15 低画质预览(速度快)。看到渐变色的 "Hello Manim" 逐字写出并放大,环境就完全就绪了。
渲染参数速查
manim -pql file.py Scene— 480p15 快速预览manim -pqm file.py Scene— 720p30 自媒体够用manim -pqh file.py Scene— 1080p60 高清导出manim -pql file.py -a— 渲染文件里全部 Scene 类
输出目录在 media/videos/<脚本名>/<画质>/ 下。更多画质、GIF、透明背景参数见《Manim 渲染输出与视频压缩》。
安装报错了?
latex not found、ffmpeg not found、pycairo 编译失败、Windows 中文路径崩溃……这些高频报错我们逐条整理在《Manim 安装报错全解(12 个高频报错)》,按报错原文索引,可直接搜索命中。