Closed AliceRixte closed 1 year ago
Could you be a bit more descriptive in what exactly you think fails with regard to positioning? I can't see any visual difference between both renderings:
TL;DR The problem is in fact that re-running the notebook cell doesn't compute a new animation
Thanks for your answer (and for the other one on Stackoverflow :-) ). In your case indeed it looks like it's working properly, so I tried to delete the whole media
folder.
After doing so, trying to execute the cell fails stating that it did not find the file :
FileNotFoundError Traceback (most recent call last)
Cell In[4], line 1
----> 1 get_ipython().run_cell_magic('manim', '-qm SpirographCranks', '\nclass SpirographCranks(Scene):\n def construct(self):\n RADIUS = .4\n dot = Dot(ORIGIN)\n line = Line(ORIGIN,RIGHT * (2-RADIUS))\n arc = Arc(arc_center=RIGHT*2, angle=PI, start_angle=PI/2, radius=RADIUS)\n \n crank = VGroup(* [dot,line,arc])\n \n self.add(crank)\n\n crank2 = crank.copy()\n def update(mobj,dt) : \n mobj.shift(crank[2].get_center() -mobj[1].get_start())\n mobj.rotate(dt*PI,about_point = mobj[1].get_start())\n\n crank2.add_updater(update)\n self.add(crank2)\n\n self.play(Rotate(crank, angle=2*PI, rate_func=linear,about_point=ORIGIN),run_time = 4)\n')
File [~\AppData\Roaming\Python\Python311\site-packages\IPython\core\interactiveshell.py:2478](https://file+.vscode-resource.vscode-cdn.net/e%3A/Documents/These/Presentations/marp-manim-template/~/AppData/Roaming/Python/Python311/site-packages/IPython/core/interactiveshell.py:2478), in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2476 with self.builtin_trap:
2477 args = (magic_arg_s, cell)
-> 2478 result = fn(*args, **kwargs)
2480 # The code below prevents the output from being displayed
2481 # when using magics with decodator @output_can_be_silenced
2482 # when the last Python token in the expression is a ';'.
2483 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File [~\AppData\Roaming\Python\Python311\site-packages\manim\utils\ipython_magic.py:163](https://file+.vscode-resource.vscode-cdn.net/e%3A/Documents/These/Presentations/marp-manim-template/~/AppData/Roaming/Python/Python311/site-packages/manim/utils/ipython_magic.py:163), in ManimMagic.manim(self, line, cell, local_ns)
156 tmpfile = (
157 Path(config["media_dir"])
158 / "jupyter"
159 / f"{_generate_file_name()}{local_path.suffix}"
160 )
162 if local_path in self.rendered_files:
--> 163 self.rendered_files[local_path].unlink()
164 self.rendered_files[local_path] = tmpfile
165 tmpfile.parent.mkdir(parents=True, exist_ok=True)
-> 1147 os.unlink(self)
1148 except FileNotFoundError:
1149 if not missing_ok:
FileNotFoundError: [WinError 3] Le chemin d’accès spécifié est introuvable: 'media\\jupyter\\SpirographCranks@2023-06-26@15-44-13.mp4'
So I had to close VS Code, open it again, and only at that point I got the proper animation.
Now, let's say I want to modify the animation by changing the first line of the update function to this :
mobj.shift(crank[0].get_center()-mobj[1].get_start())
On my computer re-running the cell doesn't generate a new video, which explains why I had the problem in a first place.
Can you reproduce that ?
I spent a bit more time on this and I noticed that the behavior I described in my previous answer ONLY happens when I modify something inside the update
function. For instance, if I change RADIUS=0.2
and rerun the cell, I get a new animation. But if I only modify the body of update
, rerunning the cell doesn't yield a new animation.
At least this gives me a work around to trigger the computation again, but this is still a weird behaviour.
rerunning the cell doesn't yield a new animation.
Manim tries to save your time by using caching of previous renderings. This caching algorithm is "ok", but it cannot catch everything. But you can fully disable it with the command line argument --disable_caching
Oooo thanks so much ! Well thank you for your time
Description of bug / unexpected behavior
The same manim Scene yields the animation I want when I use it via manim CLI, but the positionning fails when running in Jupyter notebook.
Expected behavior
The output of jupyter should be the same as the output from the CLI .
How to reproduce the issue
Code for reproducing the problem
```py from manim import * class SpirographCranks(Scene): def construct(self): RADIUS = .4 dot = Dot(ORIGIN) line = Line(ORIGIN,RIGHT * (2-RADIUS)) arc = Arc(arc_center=RIGHT*2, angle=PI, start_angle=PI/2, radius=RADIUS) crank = VGroup(* [dot,line,arc]) self.add(crank) crank2 = crank.copy() def update(mobj,dt) : mobj.shift(crank[2].get_arc_center()-mobj[1].get_start()) mobj.rotate(dt*PI,about_point = mobj[1].get_start()) crank2.add_updater(update) self.add(crank2) self.play(Rotate(crank, angle=2*PI, rate_func=linear,about_point=ORIGIN),run_time = 4) ```Additional media files
Images/GIFs
Expected output (from CLI) : : ![image](https://github.com/ManimCommunity/manim/assets/12593462/10035caa-0452-4fc8-a437-0ef51a1ddf0c) Unexpected output (from Jupyter) : ![image](https://github.com/ManimCommunity/manim/assets/12593462/729c991d-bdd9-4713-93f7-1ef08b5939e7)System specifications
System Details
- OS : Windows 11 - RAM: 32 Go - Python version (`python/py/python3 --version`): 3.11.4 - Installed modules (provide output from `pip list`): ``` Package Version ------------------- -------- asttokens 2.2.1 backcall 0.2.0 certifi 2023.5.7 charset-normalizer 3.1.0 click 8.1.3 click-default-group 1.2.2 cloup 0.13.1 colorama 0.4.6 colour 0.1.5 comm 0.1.3 debugpy 1.6.7 decorator 5.1.1 distlib 0.3.6 executing 1.2.0 filelock 3.12.2 glcontext 2.3.7 idna 3.4 ipykernel 6.23.2 ipython 8.14.0 isosurfaces 0.1.0 jedi 0.18.2 jupyter_client 8.2.0 jupyter_core 5.3.1 lxml 4.9.2 manim 0.17.3 manim-slides 4.14.0 ManimPango 0.4.3 mapbox-earcut 1.0.1 markdown-it-py 3.0.0 matplotlib-inline 0.1.6 mdurl 0.1.2 moderngl 5.8.2 moderngl-window 2.4.4 multipledispatch 0.6.0 nest-asyncio 1.5.6 networkx 2.8.8 numpy 1.25.0 opencv-python 4.7.0.72 packaging 23.1 parso 0.8.3 pickleshare 0.7.5 Pillow 9.5.0 pip 23.1.2 platformdirs 3.5.3 prompt-toolkit 3.0.38 psutil 5.9.5 pure-eval 0.2.2 pycairo 1.24.0 pydantic 1.10.9 pydub 0.25.1 pyglet 2.0.7 Pygments 2.15.1 pyrr 0.10.3 PySide6 6.5.1.1 PySide6-Addons 6.5.1.1 PySide6-Essentials 6.5.1.1 python-dateutil 2.8.2 python-pptx 0.6.21 pywin32 306 pyzmq 25.1.0 requests 2.31.0 rich 13.4.2 scipy 1.10.1 screeninfo 0.8.1 setuptools 65.5.0 shiboken6 6.5.1.1 six 1.16.0 srt 3.5.3 stack-data 0.6.2 svgelements 1.9.5 tornado 6.3.2 tqdm 4.65.0 traitlets 5.9.0 typing_extensions 4.6.3 urllib3 2.0.3 virtualenv 20.23.0 watchdog 2.3.1 wcwidth 0.2.6 wheel 0.40.0 XlsxWriter 3.1.2 ```FFMPEG
Output of `ffmpeg -version`: ``` ffmpeg version 6.0-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers built with gcc 12.2.0 (Rev10, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100 ```