首个教你怎么在Pycharm下安装Manim的教程
1. 安装环境
- Pycharm
- Git
- Manim
前两个都是程序员标配了。只需要去github download zip或者本地git clone一下Manim就可以。
2. 创建工程
把下载完成的manim放在工程主路径里,之后在pycharm的命令行中会用到。我这里的工程名字是manimPRO
,按照自己取的名字在电脑上里面找到这个文件夹放进去就行。
3. 配置
最先的一步是什么,我猜大部分人不会使用git clone下载到工程目录,这会导致你的工程还未进行git初始化,所以先在上图中进行git init
,当然也可以在pycharm的命令行里面进行初始化。
这样就可以在pycharm的命令行中使用pip安装manim需要的环境。
接下来来到pycharm中,打开命令行。
cd manim
,进入到manim的目录。
再输入pip install -e . -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
等待下载完成即可。
4. 运行
这里给一个官方的代码,按照这个代码原封不动的运行,可以得到一个只有一个点的视频。
说明你已经安装成功了。
from manimlib.imports import *
from pathlib import Path
RESOLUTION = ""
FLAGS = f"-ps {RESOLUTION}"
SCENE = "Test"
class Test(Scene):
def construct(self):
self.add(Dot())
Circle = Circle()
if __name__ == '__main__':
script_name = f"{Path(__file__).resolve()}"
os.system(f"manim {script_name} {SCENE} {FLAGS}")
5. 报错的原因
- 没进行git初始化
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It’s also possible that there is a mismatch between the package nam
e in setup.cfg and the argument given to pbr.version.VersionInfo. Project name manimlib was given, but was not able to be found.
error in setup command: Error parsing C:\Users\14215\PycharmProjects\manimPRO\manim-master\setup.cfg: Exception: Versioning for this project requires either an sdist tarball, or acc
ess to an upstream git repository. It’s also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name mani
mlib was given, but was not able to be found.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
- 没添加信任镜像源
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead,
otherwise you may silence this warning and allow it anyway with ‘–trusted-host mirrors.aliyun.com’.
ERROR: Could not find a version that satisfies the requirement argparse (from manimlib)
ERROR: No matching distribution found for argparse