Mac安装Manim

brew install py3cairo ffmpeg
brew install pango scipy
conda create manim_py39 python=3.9
conda activate manim_py39

pip install manim

若出现 unknown or unsupported macOS version: :dunno 的错误,则要升级 brew,如下:

# 查找homebrew-cask安装位置
echo $(brew --repo homebrew/homebrew-cask)
// 比如我的输出 /opt/homebrew/Library/Taps/homebrew/homebrew-cask

# 拉取完整存储库
git -C /opt/homebrew/Library/Taps/homebrew/homebrew-cask fetch

# 更新brew
brew update

# 然后再执行brew install 即可

安装好环境后来测试一个例程,编写一个 demo.py,如下,

from manim import *

class CreateCircle(Scene):
    def construct(self):
        circle = Circle()  # create a circle
        circle.set_fill(PINK, opacity=0.5)  # set the color and transparency
        self.play(Create(circle))

然后在终端执行,

manim -pql demo.py CreateCircle

这样执行成功后会在当前目录下生成 video 的文件夹,里面就包含了 CreateCircle.mp4 动画,如下:

记录 | mac安装Manim_ci


当然,这只是一个很简单的动画演示,它还有很多很酷炫的数学动画展示。