跳转到内容

如何在 macOS 上从源码构建 manimgl

Manim 是一个精确的程序化动画引擎,用于创建解释性数学视频。

Terminal window
cd ~/projects
git clone https://github.com/3b1b/manim.git
cd manim
Terminal window
conda create -n manim-build-from-source python=3.10
conda activate manim-build-from-source
Terminal window
pip install mapbox-earcut
Terminal window
brew install ffmpeg
Terminal window
brew install mactex

Type latex --version in the terminal.

Terminal window
latex --version
# Output
pdfTeX 3.141592653-2.6-1.40.26 (TeX Live 2024)
kpathsea version 6.4.0
Copyright 2024 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.43; using libpng 1.6.43
Compiled with zlib 1.3.1; using zlib 1.3.1
Compiled with xpdf version 4.04

如果输出如上所示,那么恭喜你,mactex 已成功安装。你可以继续 下一步

否则,请继续。我们需要修复这个问题。 我不确定为什么,但有时,当 brew install mactex 完成后,它只是下载一个包到你的磁盘。你仍然需要手动安装它。

Terminal window
brew info mactex
# Output
brew info mactex
==> mactex: 2024.0312
https://www.tug.org/mactex/
Installed
/opt/homebrew/Caskroom/mactex/2024.0312 (5.6GB)
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/m/mactex.rb
==> Name
MacTeX
==> Description
Full TeX Live distribution with GUI applications
==> Dependencies
ghostscript
==> Artifacts
mactex-20240312.pkg (Pkg)
==> Caveats
You must restart your terminal window for the installation of MacTeX CLI
tools to take effect.
Alternatively, Bash and Zsh users can run the command:
eval "$(/usr/libexec/path_helper)"
==> Analytics
install: 3,166 (30 days), 7,794 (90 days), 30,329 (365 days)

复制高亮的路径并在终端中打开它。

Terminal window
open /opt/homebrew/Caskroom/mactex/2024.031

你会看到一个名为 mactex-<date>.pkg 的文件

tree /opt/homebrew/Caskroom/mactex/2024.0312
/opt/homebrew/Caskroom/mactex/2024.0312
└── mactex-20240312.pkg
1 directory, 1 file

打开这个文件并手动安装。

安装完成后,重新 验证 mactex 安装,现在 mactex 应该可以正常工作。

Terminal window
pip install -e ./manim
Terminal window
which manimgl # output: /opt/anaconda3/envs/manim-build-from-source/bin/manimgl
Terminal window
cd ~/projects/manim
manimgl example_scenes.py TexTransformExample

你应该能够看到下面的动画。

恭喜你,你已经完成了所有步骤。

如果遇到安装和使用问题,可以在 这里 创建一个 Issue。

查看 示例场景 以查看库的语法、动画类型和对象类型示例。

3b1b/videos 仓库中,你可以看到所有 3blue1brown 视频的代码。