Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ValueError: [Errno 22] Invalid argument #483

Open
3 of 4 tasks
JoacoAnselmo opened this issue Oct 22, 2024 · 11 comments
Open
3 of 4 tasks

[BUG] ValueError: [Errno 22] Invalid argument #483

JoacoAnselmo opened this issue Oct 22, 2024 · 11 comments
Labels
bug Something isn't working cli Related to the command line interface

Comments

@JoacoAnselmo
Copy link

JoacoAnselmo commented Oct 22, 2024

Terms

Describe the issue

Hi! I installed manim slides, everything went well, but whenever I try to render my scene it gives an error message (although it does render, so manim is working).

Then, if I try to run manim-slides, it tells me the JSON doesn't exist.

I haven't found anything on the other issues about this. Any help would be appreciated!

(I inserted the corresponding code and error messages below, I'm hoping it shows up on the issue report, it is my first time submitting one).

Command

manim -pqh scene.py EjemploSlides

Issue Type

Other

Python version

Python 3.11.3

Python environment

Manim Slides version: 5.1.9
Python executable: C:\Users\Joaquín\AppData\Local\Programs\Python\Python311\python.exe
Manim bindings:
"sox" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
SoX could not be found!

    If you do not have SoX, proceed here:
     - - - http://sox.sourceforge.net/ - - -

    If you do (or think that you should) have SoX, double-check your
    path variables.

        manim (version: 0.18.1)
        manimgl not found
No Qt API found, some Manim Slides commands will not be available

What is your platform?

Windows

Other platform

No response

Manim Slides Python code

class EjemploSlides(Slide):
    def construct(self):
        punto = Dot(ORIGIN, color=BLUE)
        self.play(Create(punto))
        self.next_slide()

        self.play(punto.animate.shift(RIGHT))
        self.next_slide()

        self.play(FadeOut(punto))

Relevant log output

C:\Users\Joaquín\AppData\Local\Programs\Python\Python311\Lib\site-packages\manim\cli\render\comm │
│ ands.py:120 in render                                                                            │
│                                                                                                  │
│   117 │   │   │   try:                                                                           │
│   118 │   │   │   │   with tempconfig({}):                                                       │
│   119 │   │   │   │   │   scene = SceneClass()                                                   │
│ ❱ 120 │   │   │   │   │   scene.render()                                                         │
│   121 │   │   │   except Exception:                                                              │
│   122 │   │   │   │   error_console.print_exception()                                            │
│   123 │   │   │   │   sys.exit(1)                                                                │
│                                                                                                  │
│ C:\Users\Joaquín\AppData\Local\Programs\Python\Python311\Lib\site-packages\manim_slides\slide\ma │
│ nim.py:136 in render                                                                             │
│                                                                                                  │
│   133 │   │                                                                                      │
│   134 │   │   config["max_files_cached"] = max_files_cached                                      │
│   135 │   │                                                                                      │
│ ❱ 136 │   │   self._save_slides(                                                                 │
│   137 │   │   │   use_cache=not (config["disable_caching"] or self.disable_caching),             │
│   138 │   │   │   flush_cache=(config["flush_cache"] or self.flush_cache),                       │
│   139 │   │   │   skip_reversing=self.skip_reversing,                                            │
│                                                                                                  │
│ C:\Users\Joaquín\AppData\Local\Programs\Python\Python311\Lib\site-packages\manim_slides\slide\ba │
│ se.py:532 in _save_slides                                                                        │
│                                                                                                  │
│   529 │   │   │                                                                                  │
│   530 │   │   │   # We only concat animations if it was not present                              │
│   531 │   │   │   if not use_cache or not dst_file.exists():                                     │
│ ❱ 532 │   │   │   │   concatenate_video_files(slide_files, dst_file)                             │
│   533 │   │   │                                                                                  │
│   534 │   │   │   # We only reverse video if it was not present                                  │
│   535 │   │   │   if not use_cache or not rev_file.exists():                                     │
│                                                                                                  │
│ C:\Users\Joaquín\AppData\Local\Programs\Python\Python311\Lib\site-packages\manim_slides\utils.py │
│ :34 in concatenate_video_files                                                                   │
│                                                                                                  │
│    31 │   │   tmp_file = f.name                                                                  │
│    32 │                                                                                          │
│    33 │   with (                                                                                 │
│ ❱  34 │   │   av.open(tmp_file, format="concat", options={"safe": "0"}) as input_container,      │
│    35 │   │   av.open(str(dest), mode="w") as output_container,                                  │
│    36 │   ):                                                                                     │
│    37 │   │   input_video_stream = input_container.streams.video[0]                              │
│                                                                                                  │
│ in av.container.core.open:420                                                                    │
│                                                                                                  │
│ in av.container.core.Container.__cinit__:266                                                     │
│                                                                                                  │
│ in av.container.core.Container.err_check:286                                                     │
│                                                                                                  │
│ in av.error.err_check:326                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: [Errno 22] Invalid argument: 'C:\\Users\\JOAQUN~1\\AppData\\Local\\Temp\\tmp519hqu_y.txt'

# And then I get
Usage: manim-slides present [OPTIONS] [SCENES]...

Error: File slides\EjemploSlides.json does not exist, check the scene name and make sure to use Slide as your scene base class

Screenshots

No response

Additional information

This is the first time I'm using it, so there may be an installation bug or something like that

Recommended fix or suggestions

No response

@JoacoAnselmo JoacoAnselmo added the bug Something isn't working label Oct 22, 2024
@jeertmans
Copy link
Owner

jeertmans commented Oct 22, 2024

Hello @JoacoAnselmo, thanks for reporting your bug!

Can you provide the command that you run for rendering the animations?
Nevermind, you did provide it :-)

Can you try running

manim-slides render -pqh scene.py EjemploSlides

instead?

As indicated by the last line in your error traceback, the JSON file does not exist, which indicates that the rendering failed.

@jeertmans jeertmans added the cli Related to the command line interface label Oct 22, 2024
@jeertmans jeertmans changed the title [BUG] <Error 22 - Invalid argument> [BUG] ValueError: [Errno 22] Invalid argument Oct 22, 2024
@JoacoAnselmo
Copy link
Author

Hi, thanks for answering! After running that coide, I get this output:
`Usage: manim-slides render [-h] [--CE|--GL] [RENDERER_ARGS]...

Render SCENE(s) from the input FILE, using the specified renderer.

Use manim-slides render --help to see help information for a specific
renderer.

Options:
--CE If set, use Manim Community Edition (CE) renderer. If this or --GL
is not set, defaults to CE renderer. [env var: MANIM_RENDERER]
--GL If set, use ManimGL renderer. [env var: MANIMGL_RENDERER]
-h Show this message and exit.`

It's as if it didn't really run at all, I think.

A couple things that may be of interest: At first I installed manim_presentation, but after some quality issues I decided to try this instead, so maybe there's some clash there. One other thing, I've noticed that the import doesn't get properly colored in VSCode, maybe it's just visual but I thought it was worth mentioning. The "Slide" stays not colored.

image

@jeertmans
Copy link
Owner

My bad, this is because -pqh is understood as -p -q -h by manim-slides, and -h triggers the help menu. A possible workaround is:

manim-slides render -p --quality=h scene.py EjemploSlides

For your example, I can't say much unless you include a full code that I can run locally :-)

@JoacoAnselmo
Copy link
Author

Same output :(
Could it be that it isn't interpreting the file address correctly for some reason? The .txt at the address that is an "invalid argument" does exist, and it itself contains an address to a partial movie file that again, does exist.

@jeertmans
Copy link
Owner

Which error message, the first one of the second one?

@JoacoAnselmo
Copy link
Author

Sorry, the first one.

@jeertmans
Copy link
Owner

I think the error comes from Manim, not Manim Slides, but maybe I am wrong. Can you try rendering the animations without Manim Slides (so with Scene as a base class)?

If possible, use the same Python environnement, and put the output here :)

@Vasissualiyp
Copy link

Hi! Got a similar issue, but with ThreeDSlide instead. Changing to ThreeDScene allowed the scene to render without errors, but I (as expected) cannot use the mp4 output alone to do a presentation (no json is generated).

When I use ThreeDSlide and not ThreeDScene, I get the same error that Joaco described above, except it redirects me to a temporary video file that doesn't exist:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /nix/store/fdqig8w0q2dm8xvxqqncpfv7r73766ly-python3-3.12.8-env/lib/python3.12/site-packages/mani │
│ m/cli/render/commands.py:120 in render                                                           │
│                                                                                                  │
│   117 │   │   │   try:                                                                           │
│   118 │   │   │   │   with tempconfig({}):                                                       │
│   119 │   │   │   │   │   scene = SceneClass()                                                   │
│ ❱ 120 │   │   │   │   │   scene.render()                                                         │
│   121 │   │   │   except Exception:                                                              │
│   122 │   │   │   │   error_console.print_exception()                                            │
│   123 │   │   │   │   sys.exit(1)                                                                │
│                                                                                                  │
│ /nix/store/fdqig8w0q2dm8xvxqqncpfv7r73766ly-python3-3.12.8-env/lib/python3.12/site-packages/mani │
│ m_slides/slide/manim.py:136 in render                                                            │
│                                                                                                  │
│   133 │   │                                                                                      │
│   134 │   │   config["max_files_cached"] = max_files_cached                                      │
│   135 │   │                                                                                      │
│ ❱ 136 │   │   self._save_slides(                                                                 │
│   137 │   │   │   use_cache=not (config["disable_caching"] or self.disable_caching),             │
│   138 │   │   │   flush_cache=(config["flush_cache"] or self.flush_cache),                       │
│   139 │   │   │   skip_reversing=self.skip_reversing,                                            │
│                                                                                                  │
│ /nix/store/fdqig8w0q2dm8xvxqqncpfv7r73766ly-python3-3.12.8-env/lib/python3.12/site-packages/mani │
│ m_slides/slide/base.py:532 in _save_slides                                                       │
│                                                                                                  │
│   529 │   │   │                                                                                  │
│   530 │   │   │   # We only concat animations if it was not present                              │
│   531 │   │   │   if not use_cache or not dst_file.exists():                                     │
│ ❱ 532 │   │   │   │   concatenate_video_files(slide_files, dst_file)                             │
│   533 │   │   │                                                                                  │
│   534 │   │   │   # We only reverse video if it was not present                                  │
│   535 │   │   │   if not use_cache or not rev_file.exists():                                     │
│                                                                                                  │
│ /nix/store/fdqig8w0q2dm8xvxqqncpfv7r73766ly-python3-3.12.8-env/lib/python3.12/site-packages/mani │
│ m_slides/utils.py:60 in concatenate_video_files                                                  │
│                                                                                                  │
│    57 │   │   │   │   packet.stream = output_audio_stream                                        │
│    58 │   │   │   else:                                                                          │
│    59 │   │   │   │   continue  # We don't support subtitles                                     │
│ ❱  60 │   │   │   output_container.mux(packet)                                                   │
│    61 │                                                                                          │
│    62 │   os.unlink(tmp_file)  # https://stackoverflow.com/a/54768241                            │
│    63                                                                                            │
│                                                                                                  │
│ in av.container.output.OutputContainer.mux:257                                                   │
│                                                                                                  │
│ in av.container.output.OutputContainer.mux_one:278                                               │
│                                                                                                  │
│ in av.container.core.Container.err_check:286                                                     │
│                                                                                                  │
│ in av.error.err_check:326                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: [Errno 22] Invalid argument:
'slides/files/PresentationSlides_4/e7c14481ec1f7ec66fa586570ace31ac2f54e35a0c34e9da623b413e240cc1cb.m
p4'

Checking the directory it tries getting Invalid argument from, I get a bunch of short <1sec clips on which nothing is happening, which is much less than the total animation.

What is interesting, is that the entire animation gets generated (i.e. when I run with preview, it works and displays everything perfectly). But still that hashed video file is not present, so json isn't getting created.

For me, this happens when I have a "complex" 3D scene - i.e. with camera rotation in 3D mainly. When I use ThreeDSlide, but work on 2D animation, this issue doesn't appear and the code performs 100% as expected.

Any ideas what might be causing this? I'm on manim-slides v5.1.9, because it's the latest one in nixpkgs. Manim-community version v0.18.1.

@jeertmans
Copy link
Owner

Hi @Vasissualiyp, could you provide a pip freeze of your Python environment, a MWE (the simplest version of your code), your Python version, and your OS?

@candreuv
Copy link

Hi @jeertmans and @JoacoAnselmo! I have had the same problem, and I think I know the cause of the problem. It is something that happens frequently to Spanish speakers and gives us a lot of problems: tildes and blank spaces in absolute paths.

In @JoacoAnselmo case, he has a tilde in the word "Joaquín" in the path. If you open the temporary file, you will see a question mark in the path. In my case, something like: file ‘C:\Users...\Presentaci�n...’.

In my case, I solved the problem by modifying the utils.py file (in the @JoacoAnselmo case, C:\Users\Joaquín\AppData\Local\Programs\Python\Python311\Lib\site-packages\manim_slides\utils.py), by modifying the line

with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:

by

with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False, encoding="utf-8") as f:

This has fixed the error. I hope you find this helpful.

@jeertmans
Copy link
Owner

Hi @candreuv, that's an interesting bug! If that's okay for you, I would happily receive a pull request fixing this bug :-)

We could also include a test, I think, inside the tests folder, by creating a temporary directory that uses accents (e.g., with isolated_filesystem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the command line interface
Projects
None yet
Development

No branches or pull requests

4 participants