Skip to main content

My Adventures With Manim - Part 1

What is Manim?

Manim is a mathematical animation tool, built by Grant Sanderson in Python3 to animate content for his excellent YouTube channel 3Blue1Brown (I highly suggest you take a look if you like Maths and/or Science) using animations generated with code. Manim, simply put, is Grant's own personal animation tool with which he makes his content, but he was kind enough to share the source code for it on GitHub, allowing anyone to use it.

Why use Manim?

Often, abstract concepts in mathematics and science can be difficult to grasp and understand, and in cases like these, visualising the processes can be very useful. Manim was built from the ground up for this purpose of teaching maths by visualising it, and is really very good at it.

Getting Started With Manim:

Installing Manim onto your machine is an adventure in and of itself, so I thought I'd detail how I set it up on my machine, running MacOS Catalina 10.15.

Most of these steps I followed are those given by Brian Howell here. I, however, made some changes to reduce the amount of precious disk-space that Manim (and especially LaTeX) use. Following Howell's instructions will take up close to 4.5 GB of storage space, whereas the steps I detail here should only set you back by around a Gigabyte and a half, assuming you already have tools like Homebrew installed.

The process should be quite straightforward and linear. The general steps involved are:
  1. Installing Homebrew
  2. Installing the system-wide dependencies that Manim needs.
  3. Downloading, installing and configuring a TeX distribution.
  4. Creating a Python Virtual Environment and installing Manim's Python dependencies.
  5. Cloning the Manim GitHub repository and setting Manim up.
  6. Running tests to make sure everything works.

Step 1 can be omitted, but only if you're a masochist and want to install each and every system dependency Manim needs manually, as well as the dependencies those dependencies need. Good luck with FFMPEG ;)

Step 3 can be omitted, but only if you don't want to write anything with Manim, like equations. Not needing LaTeX means you get a much lighter install.

1.Installing Homebrew

Installing a package manager like Homebrew is a good idea, as you can manage all the system software you install right from one place. Installing it is simple enough:

/usr/bin/ruby -e "$(curl -fsSL"

Just put that in a Terminal prompt and let it do its thing. You might be prompted for an Admin Password, so key that in if you need to, or ask a person of authority to do it for you :)

Do note that this will also install the Xcode Command Line Developer Tools, if you didn't already have them installed.

After it finishes (the last line on the Terminal window will be like the line you typed the above command into), try running

brew doctor

You should get a message saying "Your system is ready to brew.". If you don't, the Homebrew Github issues board is a wonderful place to get any problems fixed. From here on out, any code starting with brew should be entered in a command prompt unless explicitly stated otherwise.

2.Installing Manim's System-Wide Dependencies

Python3 comes pre-installed with MacOS Catalina, and if you installed the Xcode Command Line Developer Tools, you'll also get another version of Python in the directory allocated to it. Sadly, these aren't updated very often, and it'll save us a lot of trouble if we just install another Python interpreter with Homebrew like so:

brew install python

Do note that Manim can run stably on Python 3.7. It may or may not work on other versions, depending on what the Python version introduces, so it's safest to install that specific version of Python to your system; usually though, Manim happily cooperates with almost all Python versions. I have a hunch it also works on Python 3.8 by now.


pkg-config is a helper tool used when compiling applications and libraries. It's in a bit of a grey area when it comes to whether it's actually absolutely needed when installing Manim, because no guide I consulted told me to do it, but I would always get an error installing some package or the other if I didn't. You don't have to install it, but I found it useful.
brew install pkg-config


Cairo, as its webpage states, is a 2D graphics library.

You can install it like so:

brew install cairo

It'll install some of it's own dependencies (namely libpng, freetype, fontconfig, gettext, libffi, pcre, glib, lzo and pixman), so just let it run and do its thing.


Sox is "the Swiss-Army Knife of Sound Processing". Manim uses Sox to bring audio to animations. You can install it with the command below:

brew install sox


Finally, you need FFMPEG, which is basically the A/V library to end all A/V libraries. Anything multimedia related, this library can give you.
Use the install command below:
brew install ffmpeg

It'll install a LOT of dependencies, so grab a quick snack or something.

3.Installing and configuring a TeX distribution. (optional)

LaTeX is a document preparation system. It allows Manim to write mathematical equations and can be configured to output almost anything text related. If you don't plan on writing anything with Manim, you don't need LaTeX.

There are various flavours of TeX. Brian Howell's guide recommended installing the entire distribution, but only a few of the manifold libraries it comes packaged with are actually needed.

There are two major ways to set up LaTeX for Manim. The one I see most often is installing MiKTeX or MacTeX, but to cut down on download size and disk space, I've included a way to set it up with BasicTeX as well.

Usual Way :

MiKTeX or MacTeX were the recommended flavours of TeX for Manim. Of these, MiKTeX has the capability to install missing packages on the fly, but MacTeX is purpose built for the best compatibility with MacOS. MiKTeX's primary target OS is Windows, and it hadn't been released for MacOS Catalina when I installed Manim. I'm fairly sure a version for it has been released by now, so it might be worth checking out.

You can install them each like so:
brew cask install miktex-console
brew cask install mactex
If you don't want MacTeX's user interface (you don't absolutely need it for Manim), try:
brew cask install mactex-no-gui

Note that the "cask" keyword is for installing actual ".app" applications, and you can install a large amount of ".app" applications using it.
If you install MiKTeX, be sure to configure it for your system, and turn on the feature that allows it to install TeX packages on the fly. If you go with MacTeX, you won't have to do anything with it (if it works fine), because it comes with every conceivable LaTeX package anyway.

My Way:

Now, you can safely get away with installing either of the recommended packages and be done with it, but I, personally, don't need all of this stuff, especially MiKTeX's GUI and similar things. I'd much rather stick with the barest-bone install of TeX that I can get.

Enter BasicTeX. BasicTeX gives you only the barest minimum for getting LaTeX ready. It's fast, light, and exactly what I need. It's loads smaller compared to MiKTeX's 192MB and MacTeX's astonishing 4.5 GB; it's only around 90MB. This of course means that you need to install Manim's TeX requirements using TeX's package manager tlmgr.

First, install BasicTex:
brew cask install basictex

Now, once that's done, type:
tlmgr --version

You should get a message showing the revision and TeX installation that the tool uses.

Now, we have to install the packages used by Manim. From a lot of trial and error, I found that, in order to run every single example scene perfectly, we need the following LaTeX packages:
  1. standalone
  2. preview
  3. doublestroke
  4. relsize
  5. fundus-calligra
  6. wasysym
  7. physics
  8. dvisvgm.x86_64-darwin
  9. dvisvgm
  10. rsfs
  11. wasy
  12. cm-super
The general format for installing something with tlmgr is :
tlmgr install "package"
Where "package" is the package you need to install.
So just key in:
tlmgr install standalone preview doublestroke relsize fundus-calligra wasysym physics dvisvgm.x86_64-darwin dvisvgm rsfs wasy cm-super

And let it finish. Once you've finished installing each package, we can finally move on to setting Python up for Manim.

4. Setting up a Python Environment for Manim

I'd highly recommend setting up a Python virtual environment for this. It'll help you manage the Python dependencies that Manim needs and avoid mixing them up with those from your other Python projects.

First, create a Virtual Environment using Python Venv:

python3 -m venv "directory path"

Where "directory path" is the full path to the folder where you want everything Manim related to be. To be on the safer side, I usually move to one folder above where I want to put the Virtual Environment, and create the Virtual environment from there. Something like this, where "Python" is a folder I created to put all my Python Projects in, and ManimEnv is the name of the folder/virtual environment:

cd Python
python3 -m venv ManimEnv

I'll be using ManimEnv as the name of the virtual Environment, but you can name it anything you want. I will however, refer to the environment as ManimEnv for the course of this post. Now, move into the Virtual Environment and activate it:
cd ManimEnv
source bin/activate
This moves into the folder ManimEnv and runs the script (provided by the Environment) that starts the Virtual Environment. Your command prompt should look something like this:

Note that the name of the Virtual Environment appears before each prompt now, indicating that you are inside a virtual environment.
Now, all we have to do is install each and every Python library that Manim needs.
Of course, you could clone the Manim Git repository and run pip install -r requirements.txt but I'd rather set everything up before-hand.

The Python packages that Manim needs are:
  • colour
  • data
  • decorator
  • ffmpeg 
  • funcsigs
  • future
  • latex
  • numpy
  • opencv-python
  • Pillow
  • progressbar 
  • pycairo
  • pydub
  • scipy
  • shutilwhich
  • six
  • sox
  • tempdir
  • tqdm
So just key the following command into a command prompt inside the virtual environment:

pip install colour data decorator ffmpeg funcsigs future latex numpy opencv-python Pillow progressbar pycairo pydub scipy shutilwhich six sox tempdir tqdm

Once that finishes, check if all of the packages are present by checking the output of pip freeze.

Now, we're finally ready to download and configure Manim.

5. Downloading and Configuring Manim

Now, we're finally ready to download and customise Manim.
There are, as with most things software related, multiple ways to download Manim:
  • Cloning the Manim Git repository.
  • Simply downloading the Manim repository from GitHub.
  • Installing the library as a module using Pip.
Of these, I recommend you do the first one, as it almost always guarantees you'll get the most recent, updated version of Manim, which you can continue to keep updated regularly.

The third method is a lot simpler however, but it might not get you the most recently updated version of Manim.

Method 1:

Simply navigate to the Manim Virtual Environment folder, activate the environment, and run:
git clone

Method 2:

Go to Manim's Official GitHub Page, and click clone or download, and download as ZIP.

Expand the ZIP file inside the Virtual Environment.

Method 3:

Navigate to the Virtual Environment, activate it and run:

pip install manimlib


Finally, we approach the last leg of our journey of installation. In actuality, only one single change has to be made to Manim, and even that is just to change the output directory, where it outputs video files.

Enter the "manim" folder and open the file inside the "manimlib" folder:

Navigate to Line No.26, and change the value of Media_Dir (inside the else clause), to the path of the folder you want all your Videos and other Manim output files to be stored in:

Note that if you change the directory in quotes, like I've done, you only have to provide the path starting from your Home directory, which is where all your Desktop and Document and similar folders are.
Also, the folder you ask Manim to put its output files in MUST ALREADY EXIST! It won't make it for you, and will start piping its output to a random folder named media that it'll create inside the folder you executed the Manim script from.

6.Running Tests

Manim comes with a handy file which can serve as good basepoints to learning Manim. Making sure you can run all of these example scenes is a surefire way to ensure you set up Manim properly.

Activate your virtual environment, move into the manim folder and run via

source ManimEnv/activate
cd ManimEnv/manim

Make sure you can run all the example scenes. This ensures that you have a perfectly functional install of Manim.

Once you're satisfied that everything seems to run without any errors, you can safely start making your own animations. Happy Manimating!