#๐Ÿ”’ manim doing nothing

87 messages ยท Page 1 of 1 (latest)

untold shale
#

idk whats happening but it showing nothing whenever irun the code

river arrowBOT
#

@untold shale

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

untold shale
#

linux btw

fervent fox
#

show your code

untold shale
#
from manim import *
import numpy as np

class thing(Scene):
    def construct(self):
        a = Axes(x_range=[-10, 10], y_range=[-10, 10])
        g = a.plot(lambda x: np.sin(x), color=BLUE)
        self.add(a,g)
fervent fox
#

you dont print anything

#

if you want to output something you need print

wise sand
#

also, you don't call anything.

fervent fox
#
print("hello, world")```
untold shale
fervent fox
#

you need to call the code so it actually runs

ocean dune
fervent fox
#

i dont think so

#

probably doesnt have a lot of experience

wise sand
#

Think I've seen MEU before. Do not think a troll.

fervent fox
#

over 2300 messages
he's not a troll

untold shale
#

he didnt call it

wise sand
#

You'll have to supply some more detail.

untold shale
untold shale
fervent fox
#

he probably just didnt show it

untold shale
#

he just run the code and it runs

fervent fox
#

but you need to call it

wise sand
#

You have some code. You run it. It defines a class. And then does nothing with the class.

untold shale
wise sand
#

Maybe you can show an example of the code from this 3blue1brown person?

untold shale
#

i also find other do this same thing

#

its just works on them

fervent fox
#

you need to call it

#

otherwise it wont execute

wise sand
#

All the code you cite above does is:

  • import a heap of stuff from manim
  • import numpy
  • define a class, with one method
#

All of these "do" things, but none does anything very useful for you until you make use of that class you defined.

untold shale
wise sand
#

... because you don't make an instance of the class and call its construct method.

wise sand
# untold shale scrol on the top

All I saw was this:

from manim import *
import numpy as np

class thing(Scene):
    def construct(self):
        a = Axes(x_range=[-10, 10], y_range=[-10, 10])
        g = a.plot(lambda x: np.sin(x), color=BLUE)
        self.add(a,g)
untold shale
#

yeah

#

exactly

wise sand
#

That doesn't run anything. It just imports stuff and defines a class. ..... for later use.

untold shale
#

why for other it works!!?!?!??!?!!!

wise sand
#

I have no idea, because you haven't shown use this other code.

You need an additional line or so, like this:

it = thing() # make an instance of thing
it.construct() # call the method
untold shale
#

ihave done that bruh

#

i just said

#

3 times alr

wise sand
#

No. You didn't show any of that.

untold shale
wise sand
#

Did you do this?

#

suitably adapted?

untold shale
#

huh...

untold shale
untold shale
wise sand
#

By installing the manim package, which I assume you've done since the from manim import * line apparently works.

#

I pulled that staright from the PyPI page here:
https://pypi.org/project/manim/
which also has links to installation instructions and further documentation.

untold shale
#

thats where i came from ๐Ÿ˜ญ

#

welp

wise sand
#

I've never used it. I'll look.

untold shale
#

ill go deeper into reading that then

wise sand
untold shale
#

i was installing the optional dependencies...

wise sand
#

I stuck your code in an meu.py file. Then:

python3  -m pip install manim
manim -p -ql meu.py thing
untold shale
wise sand
#

Running it did this:

[~/tmp/meu]fleet2*> manim -p -ql meu.py thing



Manim Community v0.18.1

[11/24/24 23:51:15] INFO                                                                                                                                     scene_file_writer.py:737
                             File ready at '/Users/cameron/tmp/meu/media/images/meu/thing_ManimCE_v0.18.1.png'

                    INFO     Rendered thing                                                                                                                              scene.py:247
                             Played 0 animations
[11/24/24 23:51:16] INFO     Previewed File at: '/Users/cameron/tmp/meu/media/images/meu/thing_ManimCE_v0.18.1.png'                                                   file_ops.py:231
wise sand
#

And that png file contained the image above.

#

python3 -m pip invokes my local python3 to run the pip module. The install manim tells pip to install that package, and its dependencies.

untold shale
#

hmmmm interesting ill try that

wise sand
#

We do it that way to ensure that the package gets installing in the particular python environment used by python3.

#

That install makes a manim command also, which we then use.

untold shale
#

i literaly made a custom command for my environment

#

!extend

#

no? okay...

wise sand
#

I don't know what your environment is.

untold shale
wise sand
#

There's a "Help with Manim" section on the PyPI page. It links to a discord and a reddit.

untold shale
#

command not found bru

#

do i have to activate my env?

wise sand
#

Likely. The manim command will be in the bin subdirectory of your venv, and "activate" arranges that that is in your command search path.

untold shale
#

damn manim is cracking my pc to its max power

#

even with this simple stuff....

#

tho my laptop is super weak

river arrowBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.