Installing manim and Python – manim Series: Part 1

This post is part of a series on what I learned as I taught myself how to use manim, the mathematical animation software behind the beautiful videos at 3blue1brown. Check them out if you haven’t seen any of them yet.

Important Note:  These posts are based on an earlier version of manim which uses Python 2.7.  The latest version of manim is using Python 3.  To follow along with these posts, use Python 2.7 and the May 9, 2018 commit of manim .

1.0 Installing manim and Python

To get started you will need to have Python 2.7 installed and a copy of the manim repository cloned to your computer. I recommend using Anaconda to install Python and use the virtual environment commands within Anaconda to manage the packages you need to install. I should note that I’m working in macOS so things might be a bit different in Windows or Linux.

  • Install Python 2.7 from https://www.anaconda.com/download/
  • Open a terminal and navigate to the folder you want to clone the manim files to.
  • In the terminal type git clone https://github.com/3b1b/manim.git
  • Create a virtual environment to house all the Python packages by typing conda create -n manim27 python=2.7
  • This will create an environment named manim27 (feel free to choose another name) and it will install a clean version of Python 2.7 in the environment.
  • To activate your environment type source activate manim27 on macOS and Linux systems or activate manim27 on Windows systems. If you gave your environment a different name you can replace manim27 with the name you gave to your environment.
  • In the terminal, navigate to the top-level folder of manim. You can identify this folder because it should have a file named requirements.txt.
  • To install the packages required for manim, type pip install -r requirements.txt. These packages will be installed in your virtual environment and won’t affect any other installations of Python on your system.
  • You will need to tell manim where to save your video files. Open constants.py, which is in the top-level manim directory and change the directory listed under MEDIA_DIR to be the place you want videos saved to. You will want to change Dropbox (3Blue1Brown)/3Blue1Brown Team Folder shown below to be your desired output directory:
# Things anyone wishing to use this repository for their
# own use will want to change
MEDIA_DIR = os.path.join(
os.path.expanduser('~'),
"Dropbox (3Blue1Brown)/3Blue1Brown Team Folder"
)
  • Type python extract_scene.py example_scenes.py SquareToCircle -pl. This should result in a video that shows a square turning into a circle. If this doesn’t work for you I can’t provide any tech support; I recommend you go to https://github.com/3b1b/manim/issues?q=is%3Aissue+is%3Aclosed to see the issues others have had getting manim to run.
  • The output video file will show up in a subdirectory named /animations/example_scenes/480p15/ in the directory you specified for outputs in constants.py.

There is also a Docker image available (see https://github.com/3b1b/manim at the bottom of the page) but I ran into issues getting it working on my machine.

In my next entry in this series we’ll start off creating our own animated scene.


UPDATE:  Brian Howell has put together a great set of instructions installing manim and Python 3.7 together over at http://bhowell4.com/manic-install-tutorial-for-mac/.  All of my posts are based on an older version of manim and using Python 2.7

 

Advertisements
This entry was posted in Just for Fun, Programming and tagged , , , . Bookmark the permalink.

11 Responses to Installing manim and Python – manim Series: Part 1

  1. Juan Carlos Herranz Ramos says:

    Hello,

    first of all I would like to thank you very much for this great series.

    The problem is that you said that you wouldn´t answer any technical issues and I followed the steps that you listed, one by one, but I couldn´t install manim correctly (my computer runs Windows).

    I would only like to ask you if you know anyone who has installed manim correctly on windows, because in the technical issues page that you posted my specific problem hasn´t been solved yet.

    Thank you very much in advanced.

    • Have you tried installing Docker and trying the Docker image? These are the directions from the manim README.md:

      1. Install Docker
      2. Build docker image. docker build -t manim .
      3. Run it! docker run --rm -v "$PWD/files":/app/files manim example_scenes.py WarpSquare
      • Leo Martínez says:

        Hola,
        no encuentro mi error en ninguna entrada de https://github.com/3b1b/manim/issues?q=is%3Aissue+is%3Aclosed . Lo estoy realizando en Ubuntu 16.04 y aunque he sigo todos los pasos me aparece este error:
        File “extract_scene.py”, line 283, in
        File “extract_scene.py”, line 243, in main
        module = get_module(config[“file”])
        File “extract_scene.py”, line 231, in get_module_posix
        last_module = imp.load_module(part, *load_args)
        File “/home/usr/manim/./example_scenes.py”, line 4, in
        from .big_ol_pile_of_manim_imports import *
        ValueError: Attempted relative import in non-package

        Agradecería mucho su ayuda. Muchas gracias.
        Un saludo.

      • Check out this issue on the manim github site: https://github.com/3b1b/manim/issues/258

  2. Leo Martínez says:

    Muchas gracias¡¡¡

  3. Joe says:

    HI,
    Thanks for this. I just wanted to let people know that there are also system requirements, specifically:
    – ffmpeg
    – latex
    – sox

    I had the latter two but not the first, so I kept getting error messages until I installed it.

  4. Alkspin says:

    Great tutorial!

    But now since manim’s in python 3.7, so you might want to create a Python3.7 environment, or directly using “python3 -m venv manim37″…

    And now for the MEDIA_DIR step, you can alternatively do one of the followings:
    a) Add environment constant “MEDIA_DIR” with the output directory as the value;
    b) Add a “media_dir.txt” file in the “manim” file with the output directory in it;
    c) Directly changing “constants.py” as shown above.

  5. Wheatley says:

    i cannot get the requirments.txt file to be found, do you have any idea?

  6. I actually created the enviroment manim27 with python 2.7 after cloning manim library, but I don’t understand when you say “In the terminal, navigate to the top-level folder of manim. You can identify this folder because it should have a file named requirements.txt.” I mean, how can I navigate folders in the terminal? After I activate the enviroment, the terminal only say (manim27) C:\users\pcuser>, there’s nothing on the top. I hope you could help me:)

  7. bhopro says:

    This blog is amazing and I have learned a lot from what you have done here. However, getting Manim running on my computer was a serious pain. I happened to log all of my issues/solutions and ended up turning it into a blog post. Hopefully this will be useful to those who are running on Mac.

    http://bhowell4.com/manic-install-tutorial-for-mac/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.