What is Manim?
Why use Manim?
Getting Started With Manim:
UPDATE 25/08/2020:
A few ardent members (of which I am one!) of the Manim Community have come together and taken initiative to clean up Manim, weed out bugs, add documentation, bring in new features and generally make Manim more easy to use. You can find this "Community" version of Manim over at the Manim Community's Manim fork on Github. I encourage you to use this version of Manim over 3b1b's if you want to make your own videos since, we'll be more receptive to bug fixes and contributions by the community at large. Be warned though, it's still very much in its infancy ;). If you feel like Manim could do with some improvements, feel free to take a Pull Request to the Community Edition of Manim!
The following instructions are for 3b1b's Manim, NOT for the community version. For those, you can read the Manim Community Edition README file.
Happy Manimating!
END UPDATE
- Installing Homebrew
- Installing the system-wide dependencies that Manim needs.
- Downloading, installing and configuring a TeX distribution.
- Creating a Python Virtual Environment and installing Manim's Python dependencies.
- Cloning the Manim GitHub repository and setting Manim up.
- Running tests to make sure everything works.
1.Installing Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
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
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:
brew install pkg-config
Cairo:
You can install it like so:
brew install cairo
Sox:
brew install sox
FFMPEG:
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)
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.tlmgr.
brew cask install basictex
tlmgr --version
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:
- standalone
- preview
- doublestroke
- relsize
- fundus-calligra
- wasysym
- physics
- dvisvgm.x86_64-darwin
- dvisvgm
- rsfs
- wasy
- cm-super
tlmgr
is :tlmgr install "package"
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
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
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
- pygments
pip install colour data decorator ffmpeg funcsigs future latex numpy opencv-python Pillow progressbar pycairo pydub scipy shutilwhich six sox tempdir tqdm pygments
pip freeze
.Now, we're finally ready to download and configure Manim.
5. Downloading and Configuring 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.
The third method is a lot simpler however, but it might not get you the most recently updated version of Manim.
Method 1:
git clone https://github.com/3b1b/manim.git
Method 2:
Method 3:
pip install manimlib
Customising:
constants.py
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:
Desktop
and Document
and similar folders are.media
that it'll create inside the folder you executed the Manim script from.6.Running Tests
example_scenes.py
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.manim
folder and run example_scenes.py
via manim.py
:source ManimEnv/bin/activate
cd ManimEnv/manim
python manim.py example_scenes.py
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!
Thank you very much. Very helpful.
ReplyDeleteThank you! I'm glad you like it!
DeleteThank you every much! This helped me get Manim running without hiccups and with confidence.
ReplyDeleteI'm happy it's helpful!
DeleteWhat’s the difference between 'source bin/activate' when you first create the Python virtual environment, and 'source ManimEnv/activate' after you’ve cloned Manim and are running it? (Sorry, I’m new to Python virtual environments.)
ReplyDeleteSeems you also need 'pygments'. I added that and it worked. Thanks for the good guide!
Delete"What’s the difference between 'source bin/activate' when you first create the Python virtual environment, and 'source ManimEnv/activate'"
DeleteI'm so sorry! They're actually supposed to be the same commands! I'll edit the article. Thanks for pointing it out!
"Seems you also need 'pygments'. I added that and it worked. Thanks for the good guide!"
Ah, yes. It was a pretty new addition to the repo. I'll add it to the requirements. Thanks for reminding me!
Also, you should check out the Community edition of Manim. We've cleaned up a lot of stuff and fixed a lot of bugs in it, so it's worth taking a look at!
https://github.com/ManimCommunity/manim
This comment has been removed by a blog administrator.
ReplyDelete