如何在 macOS 上从源码构建 manimgl
Manim 是一个精确的程序化动画引擎,用于创建解释性数学视频。
Manim 有两个版本,一个是由 3blue1brown 维护的个人版本,另一个是由 ManimCommunity 维护的社区版本。 本文将演示由 3blue1brown 维护的 macOS 上的个人版本。
Download source code
Section titled “Download source code”cd ~/projectsgit clone https://github.com/3b1b/manim.gitcd manim
conda create -n manim-build-from-source python=3.10conda activate manim-build-from-source
mapbox-earcut
Section titled “mapbox-earcut”pip install mapbox-earcut
ffmpeg
Section titled “ffmpeg”brew install ffmpeg
mactex
Section titled “mactex”brew install mactex
This may take a little longer.
验证 mactex 安装
Section titled “验证 mactex 安装”Type latex --version
in the terminal.
latex --version
# OutputpdfTeX 3.141592653-2.6-1.40.26 (TeX Live 2024)kpathsea version 6.4.0Copyright 2024 Han The Thanh (pdfTeX) et al.There is NO warranty. Redistribution of this software iscovered by the terms of both the pdfTeX copyright andthe Lesser GNU General Public License.For more information about these matters, see the filenamed 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.43Compiled with zlib 1.3.1; using zlib 1.3.1Compiled with xpdf version 4.04
如果输出如上所示,那么恭喜你,mactex 已成功安装。你可以继续 下一步。
否则,请继续。我们需要修复这个问题。 我不确定为什么,但有时,当 brew install mactex 完成后,它只是下载一个包到你的磁盘。你仍然需要手动安装它。
brew info mactex
# Output❯ brew info mactex==> mactex: 2024.0312https://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==> NameMacTeX==> DescriptionFull TeX Live distribution with GUI applications==> Dependenciesghostscript==> Artifactsmactex-20240312.pkg (Pkg)==> CaveatsYou must restart your terminal window for the installation of MacTeX CLItools to take effect.
Alternatively, Bash and Zsh users can run the command:
eval "$(/usr/libexec/path_helper)"
==> Analyticsinstall: 3,166 (30 days), 7,794 (90 days), 30,329 (365 days)
复制高亮的路径并在终端中打开它。
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
应该可以正常工作。
pip install -e ./manim
验证 manimgl 安装
Section titled “验证 manimgl 安装”which manimgl # output: /opt/anaconda3/envs/manim-build-from-source/bin/manimgl
这可能因系统而异,但可以通过虚拟环境的名称进行验证,只要 manimgl
来自 manim-build-from-source/bin/manimgl
目录,那么就没有问题。
使用 manimgl
Section titled “使用 manimgl”cd ~/projects/manimmanimgl example_scenes.py TexTransformExample
你应该能够看到下面的动画。
恭喜你,你已经完成了所有步骤。
如果遇到安装和使用问题,可以在 这里 创建一个 Issue。
查看 示例场景 以查看库的语法、动画类型和对象类型示例。
在 3b1b/videos 仓库中,你可以看到所有 3blue1brown 视频的代码。