The purpose of this post is to give another account of how to get Manim working on a Mac with Python 3.7, nothing more. I spent a few frustrating nights trying to get things to work, and I wanted to add my experiences to the growing resources for Manim. I highly recommend using this post in conjunction with Todd Zimmerman’s blog for learning how to use Grant Sanderson’s code.
I apologize ahead of time for including a lot of the simpler steps, but this post aims to make Manim accessible for someone with no programming background. I think Manim is relatively easy to learn once you have it installed it on your computer, so my hope is that those who don’t have much of a programming background are not inhibited by the frustration of getting this library to work and can focus on making great content.
This process should be relatively straight forward, if followed in order. The general process will involve:
- Downloading and installing Homebrew package manager and Python 3.7
- Installing necessary packages to your overall system
- Downloading and installing MacTex
- Cloning the Manim library and creating a virtual environment
- Modifying the code
- Running tests
Step 1: Downloading and Installing Hombrew and Python3
The first thing that is needed is the package manager Homebrew, which will help us install some packages that pip does not install properly. You can install Homebrew by opening Terminal and running the following line of code:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After Homebrew installed, Python can be installed by running:
brew install python3
If there is any problem during this process, I recommend turning to this video:
Once python is installed, there are a few packages that we need to get. Head back to your Terminal and run the following lines of code for packages that are needed to install (cairo, pkg-config, virtualenv).
brew install cairo
brew install pkg-config
pip3 install virtualenv
virtualenv is the only package that is absolutely needed prior to getting the Manim library, however I personally had troubles pip3 installing or brew installing the above items into a virtual environment (will get to this later). This is why I recommend installing them directly on to your system before proceeding with the tutorial .
The next step took a lot of trial and error to figure out, especially since there is little documentation on 3b1b’s git hub. Manim uses different sub packages of LaTeX, so “pip3 install latex” may not get all of all of the necessary sub-packages that are needed. I think the major problem is that many people already had different forms of LaTeX on their computers and so it is difficult to make sure everything is there when you might think you already have everything. After multiple installations and uninstallations, I found that the full installation of MacTex will do the trick, which can be found here:
Make sure you install everything — I tried taking shortcuts several times and it did not end up working.
Now that LaTeX is installed, you can go ahead and start getting the Manim library. It is generally good practice to run projects in a virtual environment, that way you can easily control where all of files and additional packages are installed too. Here are the steps I recommend:
Step 2: Create Folder for Animations
Step 3: Navigating Terminal
Head to the Manim GitHub and grab the URL to clone. Once copied, head to terminal and navigate to the folder you just made. Navigating to the specific folders within Terminal is pretty easy. You can find out what your current directory (current file path) is by typing:
You can find out what folders are are within your current directory by typing:
and you can change your directory to enter one of those folders by running:
Step 4: Clone Manim Respository
Now run the following command in Terminal to clone the Manim repository into your folder:
git clone https://github.com/3b1b/manim.git
Your folder should look something like this now (I renamed the folder to manim37):
Step 5: Set Up Virtual Environment
Now we need to set up a virtual environment. Essentially what this will do is reinstall a separate version of Python3 in the Manim folder. While operating in the virtual environment, you will be able to run Python and install packages to that specific folder rather than to the entire system. These are often used to make sure that specific versions of packages can be maintained on project-by-project basis.
To create a virtual environment, go to Terminal and navigate to the Manim folder. Now go ahead and run the following command into the Terminal:
“virtualenv” refers to the package that we installed earlier. “venv” is the name of the folder that you virtual environment will be installed to.
Now if you take a look in your Manim37 folder, there should be a folder named “venv”. If not, and the “venv” folder ended up somewhere else, you can just click and drag it into the Manim37 folder.
Step 6: Activate Virtual Environment
Now that you have virtual environment set up, you now need to enter from the terminal. Make sure your current working directory is Manim37, and then run:
Your terminal line will change and “(venv)” will appear at the beginning of the prompt:
Everything you do with Manim will need to be done within this virtual environment, that means installing additional packages, running your animation code, etc. If you reopen terminal, you will have to activate the virtual environment folder again. You can exit the virtual environment at any time by executing “deactivate“.
Step 7: pip3 install packages
Now we need to get some more packages: sox, ffmepg, latex, pycairo, etc. Go ahead and run each of the following:
pip3 install sox
pip3 install ffmpeg
pip3 install latex
pip3 install pycairo
pip3 install -r requirements.txt
This last line of code will run an install of more packages that are needed. You can take a look at the requirements.txt file within the Manim37 folder to see what exactly is needed, but once this process is done you won’t need any more packages.
Step 8: Modify Code
Now all of the packages have been downloaded, we can start fixing some of the code to match your computer. The first thing that needs to be done is to add a folder to the Manim37 directory called “output”.
Then we need to change a line of code in the file constants.py located in the Manim37 folder.
Once open, go to line 23 and find the line that says “Dropbox (3Blue1Brown)/3Blue1Brown Team Folder”
We need to change this line to match the output folder you just created. In my case, I replaced that line with “animation/manim37/output”. You should replace it with whatever your file path is (keeping in mind that “~” in the line above is a short for the file path to your home directory).
Step 9: TEST
Now we need to run a quick test to see if some of the animations are working. Still within the virtual environment, run:
python3 extract_scene.py example_scenes.py SquareToCircle -pl
This should pull up QuickTime to run your sample video. If you are having problems at this point, I recommend searching through the issues section of the Manim GitHub.
Step 10: LaTeX
All shapes and animations should be working at this point. However, to get words to work we will need to make a few more modifications to a couple files. These are the changes that worked for me.
Open utils/tex_file_writing.py and scroll down to the last two functions, and change them so that they look like this (sorry for the screenshot — currently having issues posting the code while maintaining formatting):
Step 11: Final Test
Now that those changes have been made, go ahead and try running:
python3 extract_scene.py example_scenes.py WriteStuff -pl
Hopefully all has worked for you!
If there are problems, I recommend posting an issue on 3b1b’s git hub. There are a lot more knowledgeable people there and your chances of fixing a problem are greater with the combined help.
Please comment below for suggestions on how to make this Tutorial more helpful.