EN
http://dns.baiduyun.im/news/show.php/video/66184544.html

Manim安装教程2024版Python视频制作引擎(科学概念可视化)

2025-06-24 12:00:33 来源: 新华社
字号:默认超大|打印|

0 写在前面。

在这里插入图片描述
相信很多同学即使没听说过3blue1brown#xff00c;也一定看过他们制作的视频,从独特的视角解释各种数学概念,内容包括线性代数、微积分、神经网络、傅里叶变换、四元数等晦涩难懂的知识点。比如最流行的《线性代数本质》系列视频。

那么这些视频是如何制作的呢?

PythonManim视频支持引擎-专门用于支持数学可视化的媒体引擎,3Blue1Brown的视频效果可以通过Manim和Python编程来实现。本文给出了Manim最新发行版本的安装教程,因为网上教程基本都过时了,容易踩坑。

1 效果展示。

动画1:

在这里插入图片描述
动画2:(动图总是超过大小,不能放上)。
在这里插入图片描述

2 安装教程(Windows)。

2.1 安装ffmpeg。

进入ffmpeg官网󿼌单击如图所示的按钮。

在这里插入图片描述

然后下载安装包。

在这里插入图片描述
下载后直接解压#xff0c;并设置环境变量。

在这里插入图片描述

2.2 安装Latex。

进入官网Miktex官网󿼌下载相应操作系统的安装包。

在这里插入图片描述
解压后操作安装程序.exe可以(环境变量会自动配置)。

2.3 安装dvisvgm。

进入官网dvisvgm下载相应操作系统的安装包,解压后操作安装程序即可。

在这里插入图片描述

2.4 安装Manim。

通过git bash运行以下命令。

git clone https://github.com/3b1b/manim.gitcd manim# Python依赖piphp安装 install -e .python -m pip install -r requirements.txt。

2021版重点:错误复现如下。

LaTeX Error!  Not a worry, it happens to the best of us.Traceback (most recent call last):  File "D:\Program FilesPython3Scripts\manimgl-script.py", line 33, in     sys.exit(load_entry_point('manimgl', 'console\_scripts', 'manimgl')())  File "d:\public\manim\manimlib\\_\_main\_\_.py", line 17, in main    scene.run()  File "d:\public\manim\manimlib\scene\scene.py", line 75, in run    self.construct()  File "example\_scenes.py", line 29, in construct    IntegerMatrix(matrix, include\_background\_rectangle=True),  File "d:\public\manim\manimlib\mobject\matrix.py", line 81, in __init__    self.add_brackets()  File "d:\public\manim\manimlib\mobject\matrix.py", line 111, in add_brackets    bracket_pair = Tex("".join([  File "d:\public\manim\manimlib\mobject\svg\tex\_mobject.py", line 167, in __init__    super().__init__(full_string, **kwargs)  File "d:\public\manim\manimlib\mobject\svg\tex\_mobject.py", line 42, in __init__    filename = tex_to_svg_file(full_tex)  File "d:\public\manim\manimlib\utils\tex\_file\_writing.py", line 54, in tex_to_svg_file    tex_to_svg(tex_file_content, svg_file)  File "d:\public\manim\manimlib\utils\tex\_file\_writing.py", line 62, in tex_to_svg    svg_file = dvi_to_svg(tex_to_dvi(tex_file))  File "d:\public\manim\manimlib\utils\tex\_file\_writing.py", line 97, in tex_to_dvi    with open(log_file, "r") as file:FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\Tex\cf5d7f9e579.log'

该问题的最终解决方案是配置。manim/manimlib/default_config.yml。manim/manimlib/default_config.yml。缓存路径,其中。"D:\\AIProject\\test\\manim\\tex"是。manim。

在这里插入图片描述

目录下新建的空文件夹,用于存储tex输出文件。

3 测试与开发。进入。manim。

目录下运行:

manimgl example_scenes.py OpeningManimExample。

你可以得到动画2的效果。新建。main.py。

文件,运行以下代码。
from manimlib import \*class GraphExample(Scene): def construct(self): axes = Axes((-3, 10), (-1, 8)) axes.add_coordinate_labels() self.play(Write(axes, lag_ratio=0.01, run_time=1)) # Axes.get\_graph will return the graph of a function sin_graph = axes.get_graph( lambda x: 2 \* math.sin(x), color=BLUE, ) # By default, it draws it so as to somewhat smoothly interpolate # between sampled points (x, f(x)). If the graph is meant to have # a corner, though, you can set use\_smoothing to False relu_graph = axes.get_graph( lambda x: max(x, 0), use_smoothing=False, color=YELLOW, ) # For discontinuous functions, you can specify the point of### 最后,Python崛起,风靡,由于优势多,应用领域广,被大牛认可。学习 Python 门槛很低󿀌但是它的晋升路线有很多,您可以进入机器学习、数据挖掘、大数据,CS等更先进的领域。学习 Python 门槛很低󿀌但是它的晋升路线有很多,您可以进入机器学习、数据挖掘、大数据,CS等更先进的领域。Python可以做网络应用,科学计算,#xfff00数据分析c;可以做网络爬虫,可以做机器学习,自然语言处理,可以写游戏,可以做桌面应用……Python可以做很多,你需要学好基础󿀌然后选择明确的方向。下面就给大家分享一套完整的副本 Python 学习资料󿀌给那些想学习的人 Python 小伙伴们一点帮助!#### 👉所有方向的Python学习路线👈整理Python各方向的技术点,形成各领域的知识点总结,它的用途在于,您可以根据上述知识点找到相应的学习资源,确保自己学得更全面。![](https://img-blog.csdnimg.cn/img_convert604bae65027d67fb624deb24.png)#### 👉必要的Python开发工具Ὀ工欲善其事必先利其器。在这里学习Python常用的开发软件,节省了很多时间。![](https://img-blog.csdnimg.cn/img_convertfa27617617004f7737.png)#### 👉Python全套学习视频Ὀ我们在看视频学习的时候,不能光动眼动脑不动手󿀌更科学的学习方法是在理解后使用它们,这个时候练手项目很合适。![](https://img-blog.csdnimg.cn/img_convert16ac689cb02316b2fa9c67ac40fc.png)#### 👉#x1f48实战案例;学习python就像学习数学一样c;不能只看书不做题,直接看步骤和答案会让人误以为自己都掌握了,但是遇到生题的时候还是会一筹莫展。所以在学习python的过程中,一定要记得多动手写代码,教程只需要看一两遍。![](https://img-blog.csdnimg.cn/img_convert/0d8c31c50236a205928ad8ae8a.png)#### 👉大厂面试真题👈我们学习Python一定是为了找到高薪的工作,以下面的面试题是阿里巴巴、腾讯、字节等一线互联网厂商最新的面试资料,阿里老板给出了权威的答案,刷完这套面试资料,相信大家都能找到满意的工作。![](https://img-blog.csdnimg.cn/img_convert946e47e58e503d2bcc6f464.png)**[需要这个系统学习材料的朋友,可以戳这里免费获取](https://bbs.csdn.net/topics/618317507)*****一个人可以快速行走,但是一群人可以走得更远!无论你是从事IT行业的老鸟,还是对IT行业感兴趣的新人,欢迎加入我们的圈子(技术交流、学习资源、职场吐槽、大厂推送、面试辅导),让我们一起学习成长!**。

【我要纠错】责任编辑:新华社