Running on Windows VSC the following code from the Manim examples:

from manim import *

class OpeningManimExample(Scene):
    def construct(self):
        intro_words = Text("""
            The original motivation for manim was to
            better illustrate mathematical functions
            as transformations.
        """)
        intro_words.to_edge(UP)

        self.play(Write(intro_words))
        self.wait(2)

        # Linear transform
        grid = NumberPlane((-10, 10), (-5, 5))
        matrix = [[1, 1], [0, 1]]
        linear_transform_words = VGroup(
            Text("This is what the matrix"),
            IntegerMatrix(matrix, include_background_rectangle=True),
            Text("looks like")
        )
        linear_transform_words.arrange(RIGHT)
        linear_transform_words.to_edge(UP)
        linear_transform_words.set_stroke(BLACK, 10, background=True)

        self.play(
            ShowCreation(grid),
            FadeTransform(intro_words, linear_transform_words)
        )
        self.wait()
        self.play(grid.animate.apply_matrix(matrix), run_time=3)
        self.wait()

        # Complex map
        c_grid = ComplexPlane()
        moving_c_grid = c_grid.copy()
        moving_c_grid.prepare_for_nonlinear_transform()
        c_grid.set_stroke(BLUE_E, 1)
        c_grid.add_coordinate_labels(font_size=24)
        complex_map_words = TexText("""
            Or thinking of the plane as $\\mathds{C}$,\\\\
            this is the map $z \\rightarrow z^2$
        """)
        complex_map_words.to_corner(UR)
        complex_map_words.set_stroke(BLACK, 5, background=True)

        self.play(
            FadeOut(grid),
            Write(c_grid, run_time=3),
            FadeIn(moving_c_grid),
            FadeTransform(linear_transform_words, complex_map_words),
        )
        self.wait()
        self.play(
            moving_c_grid.animate.apply_complex_function(lambda z: z**2),
            run_time=6,
        )
        self.wait(2)

yields an error message:

    class OpeningManimExample(Scene):
                              ^^^^^
NameError: name 'Scene' is not defined. Did you mean: 'scene'?

[Done] exited with code=1 in 0.901 seconds

However, I have code for Manim with exactly the same structure, i.e. the from manim import * following by a class NameOfTheClass(Scene): that run perfectly well.

If I look up this error online I get posts that prompt to install Manim, discuss downloading the package versus pip installing, etc. However, is the error really about Scene? Because if this is the case it would happen in all Manim files with this structure, wouldn't it?

Trying from the terminal from manimlib import * also seems to be a problem, even though manimlib is installed:

PS C:\Users\j\Documents\MANIM> from manimlib import *
ParserError: 
Line |
   1 |  from manimlib import *
     |  ~~~~
     | The 'from' keyword is not supported in this version of the language.

Directory:

enter image description here


This is the output of

import manimlib; print(dir(manimlib))

[Running] python -u "c:\Users\anton\Documents\MANIM\test.py"
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'animation', 'camera', 'config', 'constants', 'container', 'extract_scene', 'main', 'manimlib', 'mobject', 'scene', 'utils']

[Done] exited with code=0 in 8.02 seconds
0

There are 0 best solutions below