Package: manimlib
Manim is an animation engine for explanatory math videos. It's used to create precise animations programmatically, as seen in the videos at3Blue1Brown.This repository contains the version of manim used by 3Blue1Brown. There is also a community maintained version athttps://github.com/ManimCommunity/manim/.
To get help or to join the development effort, please join thediscord.InstallationManim runs on Python 3.6 or higher version. You can install it from PyPI via pip:pip3installmanimlibSystem requirements arecairo,ffmpeg,sox(optional, if you want to play the prompt tone after running),latex(optional, if you want to use LaTeX).You can now use it via themanimcommand. For example:manimmy_project.pyMySceneFor more options, take a look at theUsing manimsections further below.DirectlyIf you want to hack on manimlib itself, clone this repository and in that directory execute:# Install python requirementspython3-mpipinstall-rrequirements.txt# Try it outpython3./manim.pyexample_scenes.pySquareToCircle-plDirectly (Windows)Install FFmpeg.Install Cairo. For most users,pycairo‑1.18.0‑cp37‑cp37m‑win32.whlwill do fine (you can download it or other versions fromhere).pip3installC:\path\to\wheel\pycairo‑1.18.0‑cp37‑cp37m‑win32.whlInstall a LaTeX distribution.MiKTeXis recommended.Install SoX.Install the remaining Python packages.gitclonehttps://github.com/3b1b/manim.gitcdmanim
pip3install-rrequirements.txt
python3manim.pyexample_scenes.pySquareToCircle-plAnaconda InstallInstall sox and latex as above.Create a conda environment usingconda env create -f environment.ymlWINDOWS ONLYInstallpyreadlineviapip install pyreadline.UsingvirtualenvandvirtualenvwrapperAfter installingvirtualenvandvirtualenvwrappergitclonehttps://github.com/3b1b/manim.git
mkvirtualenv-amanim-rrequirements.txtmanim
python3-mmanimexample_scenes.pySquareToCircle-plUsing DockerSince it's a bit tricky to get all the dependencies set up just right, there is a Dockerfile and Compose file provided in this repo as well asa premade image on Docker Hub. The Dockerfile contains instructions on how to build a manim image, while the Compose file contains instructions on how to run the image.The prebuilt container image has manim repository included.INPUT_PATHis where the container looks for scene files. You must set theINPUT_PATHenvironment variable to the absolute path containing your scene file and theOUTPUT_PATHenvironment variable to the directory where you want media to be written.Install DockerInstall Docker ComposeRender an animation:INPUT_PATH=/path/to/dir/containing/source/code\OUTPUT_PATH=/path/to/output/\docker-composerunmanimexample_scenes.pySquareToCircle-lThe command needs to be run as root if your username is not in the docker group.You can replaceexample.scenes.pywith any relative path from yourINPUT_PATH.After running the output will say files ready at/tmp/output/, which refers to path inside the container. YourOUTPUT_PATHis bind mounted to this/tmp/outputso any changes made by the container to/tmp/outputwill be mirrored on yourOUTPUT_PATH./media/will be created inOUTPUT_PATH.-pwon't work as manim would look for video player in the container system, which it does not have.The first time you execute the above command, Docker will pull the image from Docker Hub and cache it. Any subsequent runs until the image is evicted will use the cached image.
Note that the image doesn't have any development tools installed and can't preview animations. Its purpose is building and testing only.Using manimTry running the following:python3-mmanimexample_scenes.pySquareToCircle-plThe-pflag in the command above is for previewing, meaning the video file will automatically open when it is done rendering. The-lflag is for a faster rendering at a lower quality.Some other useful flags include:-sto skip to the end and just show the final frame.-n <number>to skip ahead to then'th animation of a scene.-fto show the file in finder (for OSX).SetMEDIA_DIRenvironment variable to specify where the image and animation files will be written.Look through theold_projectsfolder to see the code for previous 3b1b videos. Note, however, that developments are often made to the library without considering backwards compatibility with those old projects. To run an old project with a guarantee that it will work, you will have to go back to the commit which completed that project.While developing a scene, the-spflags are helpful to just see what things look like at the end without having to generate the full animation. It can also be helpful to use the-nflag to skip over some number of animations.DocumentationDocumentation is in progress ateulertour.com/docs. And there is also an all-in-one documentation and tutorials maintained by@manim-kindergarten:manim.ml(in Chinese).WalkthroughTodd Zimmerman put together atutorialon getting started with manim, which has been updated to run on Python 3.7.manim-kindergartenwrote and collected some useful extra classes and some codes of videos inmanim_sandbox repo.ContributingOnly accepts pull requests that fixes bugs / fixes typos / improves existing content (for more information, see#1243). Most pull requests should be directed to thecommunity version.LicenseAll files in the directoryfrom_3b1b, which by and large generate the visuals for 3b1b videos, are copyright 3Blue1Brown.The general purpose animation code found in the remainder of the repository, on the other hand, is under the MIT license.