Search on blog:

Manim: How to run Manim code easier

In documentation you can see that you can run manim code in console

manim -p -ql script.py Scene1 Scene2 Scene3

where

-p        :preview after rendering
-ql       :quality low
script.py :file with manim code
Scene     :class name(s) in manim code

To make life easier you can run it directly in code using subproceesing.

if __name__ == '__main__':
    import subprocess
    subprocess.run(['manim', '-p', '-ql', __file__, 'Scene1', 'Scene2', 'Scene3'])

Or you can use function manim.main() for this

if __name__ == '__main__':
    import sys
    from manim.__main__ import main

    #sys.argv = ['manim', '--help']
    sys.argv = ['manim', '-p', '-ql', __file__, 'Scene1', 'Scene2', 'Scene3']

    main()

If you like it
Buy a Coffee