4

I have been programming with python for about half a year, and I would like to try manim ( the animation programme of 3blue1brown from youtube), but I am not sure where to start. I have not installed it, but I have tried to read up on it. And to be honest I do not understand much of the requirements of the program, and how to run it.

Google has left me without much help, so I decided to check here to see if anyone here is able to help.

From what I understand, you run manim directly in python and the animations are based on a textfile with code i assume is LaTex. I have almost no experience with python itself, but I have learned to use it through Thonny, and later Pycharm.

My main questions are: (Good sources to how to do this without being a wizard would be really helpful if they exist☺️)

  • Is it possible to install manim in pycharm, and how? Do i need some extra stuff installed to pycharm in order to run it? (I run a windows 64-bit computer)

  • If i manage to do this in pycharm, Will I then be able to code the animations directly in pycharm (in .py or .txt files), or is it harder to use in pycharm?

All help or insights is very appreciated As I said I am not extremely knowledgeable in computers, but I am enjoying learning how to code and applications of coding

4 Answers4

1

I recommend you this playlist
I always uses pycharm for manim.
Firstly i setup python interpreter by just open File->Settings->Projet->Project Interpreter then just press on little gear icon to add python interpreter to Existing environment and locate C:\Python3x\python.exe screenshot

Then just open a terminal from left-down corner and run some basic commands to run manim as mentioned in tutorials or manim github page. terminal

Navpreet Devpuri
  • 503
  • 4
  • 19
1

Something that works nicely for me is to run manimgl.exe from Python in PyCharm using the subprocess module. It also goes well with using the run shortcut while iterating with small edits.

I like to do this from the script in which my main scene is defined, for example, I have main.py which defines MyScene:

from manimlib import *


class MyScene(Scene):

    def construct(self):
        ...
 

if __name__ == '__main__':

    import subprocess

    params = 'manimgl main.py MyScene -c WHITE'.split()
    subprocess.run(params,
                   check=True,
                   capture_output=True,
                   text=True)

    # Possibly look at captured output here

The code inside if __name__ ... does not execute when the same script is loaded by manim. What is nice is that one can easily add automation steps before or after the actual execution if needed and it keeps everything related in a single script.

Edit: I also end the animations in the construct() method of MyScene with exit() to terminate the preview. I honestly don't know if this is good practice, but it works well for my usage pattern.

Note that this does require that manimgl.exe reside somewhere that is in your path, in my case (Windows) I installed this for my global Python interpreter. I followed the instructions on GitHub and it works for me because the following is in my path:

C:\Users\XXX\AppData\Local\Programs\Python\Python38\Scripts\

It may vary depending on where your Python is installed. For a venv, you could do something like:

params = '.\venv\Scripts\manimgl.exe ...'.split()

0

To run manim directly as a PyCharm run configuration, use a Shell Script run configuration. Say you have a project configured and imported the manim library, add the run configuration by inserting the path to the manim executable as the Script path and, taking the example from the manim quickstart, scene.py CreateCircle as the Script options.

run configuration

output

Marv
  • 3,517
  • 2
  • 22
  • 47
-1

Yes, you can

1.Write your code in pycharm

2.save it

3.copy that .py file to where you installed manim. In my case, it is

This pc>> C drive >> manim-master >> manim-master

4.select on the path and type "cmd" to open terminal from there

  1. Type this on the terminal

python -m manim -pql projectname.py

This will do. To play back the animation or image, open the media folder.

Sophile
  • 287
  • 3
  • 16