jeertmans / manim-slides

Tool for live presentations using manim
https://manim-slides.eertmans.be
MIT License
446 stars 48 forks source link

[BUG] When Running Manim Slides it gives me typeError #400

Closed NikoMolecule closed 6 months ago

NikoMolecule commented 6 months ago

Description

I'm trying to run manim-slides, but it gives me this very weird error. i cant even access the version of it. this is what error looks like:

Traceback (most recent call last):
  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python39\Scripts\manim-slides.exe\__main__.py", line 4, in <module>
  File "C:\Python39\lib\site-packages\manim_slides\__main__.py", line 8, in <module>
    from .convert import convert
  File "C:\Python39\lib\site-packages\manim_slides\convert.py", line 89, in <module>
    class Converter(BaseModel):  # type: ignore
  File "C:\Python39\lib\site-packages\manim_slides\convert.py", line 90, in Converter
    presentation_configs: conlist(PresentationConfig, min_length=1)  # type: ignore[valid-type]
  File "C:\Python39\lib\site-packages\pydantic\types.py", line 869, in conlist
    return Annotated[List[item_type], annotated_types.Len(min_length or 0, max_length)]
TypeError: Len() takes no arguments

This is my code:

from manimlib import *
from manim_slides import Slide
import numpy as np

# To watch one of these scenes, run the following:
# manimgl example_scenes.py OpeningManimExample
# Use -s to skip to the end and just save the final frame
# Use -w to write the animation to a file
# Use -o to write it to a file and open it once done
# Use -n <number> to skip ahead to the n'th animation of a scene.

class rectangle(Slide):
    def construct(self):
        box1 = Rectangle(stroke_color = RED_C, stroke_opacity = 0.7, fill_color = RED_B, fill_opacity=0.5, height = 1, width = 2).shift(3 * RIGHT)
        name1 = Text("Discriminator D(z)", font_size = 18).move_to(box1.get_center())

        box2 = Rectangle(stroke_color = GREEN_C, stroke_opacity = 0.7, fill_color = GREEN_B, fill_opacity=0.5, height = 1, width = 2).shift(2.5 * DOWN + 3.75 * LEFT)
        name2 = Text("Generator G(z)", font_size = 18).move_to(box2.get_center())

        box3 = Rectangle(stroke_color = GREY_A, stroke_opacity = 0.7, fill_color = BLACK, fill_opacity=0, height = 2, width = 2).shift(2.5 * UP + 1 * LEFT)
        name3 = Text("Real Images", font_size = 18).move_to(box3.get_top())

        image1r = ImageMobject("../manim/logo/10.jpg").scale(0.25).move_to(box3.get_center()).shift(0.5 * UP + 0.5 * LEFT)
        image2r = ImageMobject("../manim/logo/1012.jpg").scale(0.25).move_to(box3.get_center()).shift(0.5 * UP + 0.5 * RIGHT)
        image3r = ImageMobject("../manim/logo/1022.jpg").scale(0.25).move_to(box3.get_center()).shift(0.5 * DOWN + 0.5 * LEFT)
        image4r = ImageMobject("../manim/logo/1032.jpg").scale(0.25).move_to(box3.get_center()).shift(0.5 * DOWN + 0.5 * RIGHT)

        box4 = Rectangle(stroke_color = GREY_A, stroke_opacity = 0.7, fill_color = BLACK, fill_opacity=0.5, height = 2, width = 1).shift(2.5 * DOWN + 5.6 * LEFT)
        name4 = Text("\n 0.000 \n -0.234 \n -3.456 \n 1.293 \n 0.015 \n ... \n -1.102 \n 0.998 \n -0.122", font_size = 18).move_to(box4.get_center())

        brace1 = Brace(box4, LEFT)
        name5 = Text("100", font_size = 18).next_to(brace1, LEFT)
        name6 = Text("Random Noise", font_size = 18).next_to(box4, 0.25 * TOP)

        box7 = Rectangle(stroke_color = GREY_A, stroke_opacity = 0.7, fill_color = BLACK, fill_opacity=0, height = 2, width = 2).shift(2.5 * DOWN + 1 * LEFT)
        name7 = Text("Fake Images", font_size = 18).move_to(box7.get_bottom())

        image1f = ImageMobject("../manim/logo/generated_plot_epoch-960.png").scale(0.25).move_to(box7.get_center()).shift(0.5 * UP + 0.5 * LEFT)
        image2f = ImageMobject("../manim/logo/generated_plot_epoch-961.png").scale(0.25).move_to(box7.get_center()).shift(0.5 * UP + 0.5 * RIGHT)
        image3f = ImageMobject("../manim/logo/generated_plot_epoch-962.png").scale(0.25).move_to(box7.get_center()).shift(0.5 * DOWN + 0.5 * LEFT)
        image4f = ImageMobject("../manim/logo/generated_plot_epoch-963.png").scale(0.25).move_to(box7.get_center()).shift(0.5 * DOWN + 0.5 * RIGHT)

        arrow_1 = Arrow(start = box3.get_right(), end = box1.get_left(), color = WHITE)
        arrow_2 = Arrow(start = box7.get_right(), end = box1.get_left(), color = WHITE)
        arrow_3 = Arrow(start = box2.get_right(), end = box7.get_left(), color = WHITE)
        arrow_4 = Arrow(start = box4.get_right(), end = box2.get_left(), color = WHITE)

        self.play(ShowCreation(box4), ShowCreation(name4), ShowCreation(brace1), ShowCreation(name5), ShowCreation(name6))
        self.next_slide()

        self.play(ShowCreation(arrow_4), ShowCreation(box2), ShowCreation(name2))
        self.next_slide()

        self.play(ShowCreation(arrow_3), ShowCreation(box7), ShowCreation(name7), ShowCreation(image1f), ShowCreation(image2f), ShowCreation(image3f), ShowCreation(image4f))
        self.play(ShowCreation(box3), ShowCreation(name3), ShowCreation(image1r), ShowCreation(image2r), ShowCreation(image3r), ShowCreation(image4r))
        self.next_slide()

        self.play(ShowCreation(arrow_1), ShowCreation(arrow_2), ShowCreation(box1), ShowCreation(name1))
        self.wait()

And this is what i tried to run:

manim-slides .\example_scenes.py rectangle

Version

I can't access it, because it gives me that error when checking version

Platform

Windows

Screenshots

No response

Additional information

No response

jeertmans commented 6 months ago

Hello @NikoMolecule, thank you for reporting this issue!

If manim-slides --version fails, can you show what pip show manim_slides outputs?

Second, manim-slides .\example_scenes.py rectangle is not a valid command.

If you want to render the slide, please use manim-slides render --GL .\example_scenes.py rectangle. If you want to present them, please use manim-slides rectangle.

NikoMolecule commented 6 months ago

Hi @jeertmans when using pip show manim_slides it outputs this:

Name: manim-slides
Version: 5.1.3
Summary: Tool for live presentations using manim
Home-page:
Author:
Author-email: Jérome Eertmans <jeertmans@icloud.com>
License: MIT
Location: c:\python39\lib\site-packages
Requires: av, click, click-default-group, jinja2, lxml, numpy, opencv-python, pillow, pydantic, pydantic-extra-types, python-pptx, qtpy, requests, rich, rtoml, tqdm
Required-by:

and when running both of the lines u told me to use when rendering slide, it still gave me same error.

jeertmans commented 6 months ago

Can you check the version of Pydantic? pip show pydantic

NikoMolecule commented 6 months ago

@jeertmans it outputed this:

Name: pydantic
Version: 2.6.4
Summary: Data validation using Python type hints
Home-page:
Author:
Author-email: Samuel Colvin <s@muelcolvin.com>, Eric Jolibois <em.jolibois@gmail.com>, Hasan Ramezani <hasan.r67@gmail.com>, Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>, Terrence Dorsey <terry@pydantic.dev>, David Montague <david@pydantic.dev>, Serge Matveenko <lig@countzero.co>, Marcelo Trylesinski <marcelotryle@gmail.com>, Sydney Runkle <sydneymarierunkle@gmail.com>, David Hewitt <mail@davidhewitt.io>
License:
Location: c:\python39\lib\site-packages
Requires: annotated-types, pydantic-core, typing-extensions
Required-by: inflect, manim-slides, pydantic-extra-types
jeertmans commented 6 months ago

Are you using Python 3.9.7? Looks like this is an issue due to this Python version, see https://github.com/microsoft/semantic-kernel/issues/4430#issuecomment-1912617602 and https://github.com/pydantic/pydantic/issues/7745#issuecomment-1748812800. The best solution might be to upgrade your Python version :-)

NikoMolecule commented 6 months ago

@jeertmans I deleted python 3.9.7. and installed 3.11.9 and now when typing manim-slides --version i get this error:

'manim-slides' is not recognized as an internal or external command,
operable program or batch file.

even tho pip show manim-libs prints output

jeertmans commented 6 months ago

@jeertmans I deleted python 3.9.7. and installed 3.11.9 and now when typing manim-slides --version i get this error:

'manim-slides' is not recognized as an internal or external command,
operable program or batch file.

even tho pip show manim-libs prints output

This just means you either did not install Manim slides correctly, or that the script is installed in a folder that is not located in PATH. Google that error and you should find a solution, this is a very common issue :)

NikoMolecule commented 6 months ago

@jeertmans well i tried to fix it and when calling python -m manim-slides i got this error:

C:\Program Files\Python311\python.exe: No module named manim-slides.__main__; 'manim-slides' is a package and cannot be directly executed
jeertmans commented 6 months ago

@jeertmans well i tried to fix it and when calling python -m manim-slides i got this error:

C:\Program Files\Python311\python.exe: No module named manim-slides.__main__; 'manim-slides' is a package and cannot be directly executed

You need to use an underscore « _ » instead of the hyphen when you call it via Python modules :) So it is manim_slides and not manim-slides.