如何在Python 3.7中运行manim示例?

lf3rwulv  于 2023-06-07  发布在  Python
关注(0)|答案(4)|浏览(238)

我正在尝试使用Windows 10和Python 3.7运行manim。我已经按照https://www.youtube.com/watch?v=ZltiKHFWmv8&t=695s的说明操作了。
我下载了MikTex和Sox并成功安装了所有要求。

C:\Users\...>python -m pip install -r manim\requirements.txt
Requirement already satisfied: argparse in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 1)) (1.4.0)
Requirement already satisfied: colour in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 2)) (0.1.5)
Requirement already satisfied: numpy in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 3)) (1.19.1)
Requirement already satisfied: Pillow in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 4)) (7.0.0)
Requirement already satisfied: progressbar in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 5)) (2.5)
Requirement already satisfied: scipy in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 6)) (1.4.1)
Requirement already satisfied: tqdm in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 7)) (4.47.0)
Requirement already satisfied: opencv-python in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 8)) (4.3.0.36)
Requirement already satisfied: pycairo in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 9)) (1.19.1)
Requirement already satisfied: pydub in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 10)) (0.24.1)
Requirement already satisfied: pygments in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 11)) (2.6.1)
Requirement already satisfied: pyreadline in c:\users\hallo.desktop-4ovso14\anaconda3\lib\site-packages (from -r manim\requirements.txt (line 12)) (2.1)

我尝试了以下变体来运行SquareToCircle示例:

C:\Users\...>python -m manimlib example_scenes.py SquareToCircle -pl
C:\Users\...\Anaconda3\python.exe: No module named manimlib.__main__; 'manimlib' is a package and cannot be directly executed

产生错误。

C:\Users\...>python -m manim example_scenes.py SquareToCircle -pl
C:\Users\...\Anaconda3\python.exe: No module named manim.__main__; 'manim' is a package and cannot be directly executed

产生错误。

C:\Users\...>python3 -m manim example_scenes.py SquareToCircle -pl

不做任何事情。
SquareToCircle()添加到example_scenes.py的末尾并运行它会显示如下内容

Animation 1: TransformSquare:  67%|######6   | 40/60 [00:00<00:00, 60.62it/s]

最后产生

Played 3 animations

而不显示期望的视频。

aor9mmx1

aor9mmx11#

我不知道确切的原因,但是在Pycharm的终端中运行python -m manim example_scenes.py SquareToCircle -pl并没有产生预期的结果。

tyg4sfes

tyg4sfes2#

如果你得到了Played 3 Animations,那么很可能有一个media文件夹创建在同一个目录中的文件,其中视频文件将产生。
我在.\media\videos\1440p60\SquareToCircle.mp4上找到了这个文件。

wlp8pajw

wlp8pajw3#

我也有同样的问题。我必须下载ffmpeg,将其解压缩到一个永久位置,并将其添加到路径高级系统属性的\bin文件。然后打开命令提示符并键入manim render FILEPATH。视频将在Windows\system32\media\videos下的文件夹中。

3okqufwl

3okqufwl4#

我认为问题在于您没有从Manim目录运行manim命令。为此,必须将目录更改为manim目录(可能只需在命令提示符下键入cd manim)。

相关问题