krassowski / jupyter-manim Goto Github PK
View Code? Open in Web Editor NEWmanim cell magic for IPython/Jupyter to show the output video
License: MIT License
manim cell magic for IPython/Jupyter to show the output video
License: MIT License
Hi @krassowski,
At the moment, some people (including me) are hardly working on making manim more user-friendly in the manim-community repo: https://github.com/ManimCommunity/manim
We are actively developing new versions which are quite good by now, and we are also thinking about improving the jupyter notebook support.
Therefore I have an unusual question:
How would you feel to transfer the jupyter-manim repo to the manim-community Github Organization?
We would then try to enhance some features, and even maybe add a new java-script renderer.
Self-explanatory we would give you credits and that you created this repo first place, and keep a MIT license.
Hi, I run pip3 install jupyter_manim, everything is installed successfully but below
Building wheels for collected packages: pycairo
Building wheel for pycairo (PEP 517) ... error
ERROR: Failed building wheel for pycairo
Running setup.py clean for pycairo
Failed to build pycairo
ERROR: Could not build wheels for pycairo which use PEP 517 and cannot be installed directly
I've checked travis.yml, which I guess what "pip3 install jupyter_manim" follow. Google colab provide linux vm so I think it shouldn't install pycario?
Anyway, Should I run command line by line like this
Hi, thanks for the great job for bring manim to jupyter!
I'm just wondering if we can have the feature as written in the readme?
In future, an option to export the current namespace (or specific variables) will be added. It could be implemented by pickling the Python locals and globals and then pre-pending the cell with an un-pickling script
It will be very helpful!
I just get the error message
~/anaconda3/lib/python3.7/site-packages/manimlib-0.1.4-py3.7.egg/manimlib/__init__.py in <module>
1 #!/usr/bin/env python
2 import manimlib.config
----> 3 import manimlib.extract_scene
4 import manimlib.stream_starter
5
~/anaconda3/lib/python3.7/site-packages/manimlib-0.1.4-py3.7.egg/manimlib/extract_scene.py in <module>
7 import traceback
8
----> 9 from manimlib.scene.scene import Scene
10 from manimlib.utils.sounds import play_error_sound
11 from manimlib.utils.sounds import play_finish_sound
~/anaconda3/lib/python3.7/site-packages/manimlib-0.1.4-py3.7.egg/manimlib/scene/scene.py in <module>
9 from manimlib.animation.creation import Write
10 from manimlib.animation.transform import MoveToTarget, ApplyMethod
---> 11 from manimlib.camera.camera import Camera
12 from manimlib.constants import *
13 from manimlib.container.container import Container
~/anaconda3/lib/python3.7/site-packages/manimlib-0.1.4-py3.7.egg/manimlib/camera/camera.py in <module>
7 from PIL import Image
8 from scipy.spatial.distance import pdist
----> 9 import cairo
10 import numpy as np
11
ModuleNotFoundError: No module named 'cairo'
But manim is working properly on my system.
I guess there is some kind of version conflict.
Is this project acutally still in development?
I think the idea of connecting manim with notebooks is beautiful and has a lot of potential!
I was trying to create a binder build for jupyter-manim. I was expecting to execute all custom animation which I create with 3b1b/manim. As it need a lot of installation (for me, I was unable to set up manim in my Ubuntu 20.04), I was thinking to use binder as an alternative. But I got the following error when I use %%manim CustomAnimation
:
/home/jovyan/jupyter_manim/__init__.py:302: UserWarning: Could not find path in the manim output
warn('Could not find path in the manim output')
/tmp/tmpb6smavun.py:39: UserWarning: Import from notebook: name already in the globals(), skipping
warn('Import from notebook: ' + name + ' already in the globals(), skipping')
Traceback (most recent call last):
File "/srv/conda/envs/notebook/lib/python3.7/site-packages/manimlib/extract_scene.py", line 155, in main
scene = SceneClass(**scene_kwargs)
File "/srv/conda/envs/notebook/lib/python3.7/site-packages/manimlib/scene/scene.py", line 75, in __init__
self.construct()
File "/tmp/tmpb6smavun.py", line 94, in construct
title = TextMobject("Simpsons Rule").scale(2)
File "/srv/conda/envs/notebook/lib/python3.7/site-packages/manimlib/mobject/svg/tex_mobject.py", line 148, in __init__
self, self.arg_separator.join(tex_strings), **kwargs
File "/srv/conda/envs/notebook/lib/python3.7/site-packages/manimlib/mobject/svg/tex_mobject.py", line 44, in __init__
self.template_tex_file_body
File "/srv/conda/envs/notebook/lib/python3.7/site-packages/manimlib/utils/tex_file_writing.py", line 21, in tex_to_svg_file
dvi_file = tex_to_dvi(tex_file)
File "/srv/conda/envs/notebook/lib/python3.7/site-packages/manimlib/utils/tex_file_writing.py", line 72, in tex_to_dvi
"See log output above or the log file: %s" % log_file)
Exception: Latex error converting to dvi. See log output above or the log file: /home/jovyan/media/Tex/fa57ceb432d6961f.log
Is there any way to build this as ManimCommunity has one. I have some discussion on this on Reddit
I properly installed manim and can get the example_scenes.py to render.
I properly installed jupyter manim and conda list shows it:
jupyter-manim 0.11 pypi_0 pypi
I started jupyter notebook from a terminal initiated from within the manim folder
I entered this in the first cell:
%%manim Shapes
from manimlib.scene.scene import Scene
from manimlib.mobject.geometry import Circle
from manimlib.animation.creation import ShowCreation
class Shapes(Scene):
def construct(self):
circle = Circle()
self.play(ShowCreation(circle))
and got
UsageError: Cell magic %%manim
not found.
I completed the installation:
pip.exe install manimlib
pip.exe install jupyter_manim
when I executed this code:
from manimlib.imports import *
import jupyter_manim
%%manim Shapes
class Shapes(Scene):
def construct(self):
circle = Circle()
self.play(ShowCreation(circle))
The jupyter console displays this error: UsageError: Line magic function %%manim
not found.
How do I fix it?
Windows 10
Visual Studio Code
Python 3.9
I have a bunch of errors with this:
!pip3 install jupyter-manim
Hi,
First of all, what a wonderful extension! I'm new to this Jupyter-world, but not so much for manim, but I was wondering how one could integrate manim into a Jupyter-book and not a Jupyter-notebook. Also, the animation should auto-render when building the book. Is this possible?
Thank you in advance :-)
Hi! I've been trying jupyter-manim, and it's awesome, so thank you very much for building it!
However, I've noticed the embedded player seems to lag quite a bit on playback, so animations look a bit choppy. The rendering itself works great, and if I download the animation and play the file with Quicktime it also plays perfectly. I'm wondering if this is a known issue, or something going on with my setup. I'm running on a core i9 so I don't think my hardware would be the cause.
I don't know if this only happens to me.
Given this example, when I run the code. The video output doesn't play.
The video file output is present and can be played but in jupyter manim output, it doesn't play. I test by removing source
from video
tag and adding src
attribute in video
tag and it works. I'll make a PR for this issue if this issue is valid.
The manim output should play.
jupyter core : 4.7.0
jupyter-notebook : 6.1.6
qtconsole : 5.0.1
ipython : 7.19.0
ipykernel : 5.4.2
jupyter client : 6.1.7
jupyter lab : not installed
nbconvert : 6.0.7
ipywidgets : 7.6.2
nbformat : 5.0.8
traitlets : 5.0.5
When I run this piece of code, I get an unexpected result. It should be writing out \sum_{j=0}^\infty x_j
fully then after two seconds adding brackets around it, but it draws half of the left one first and then completes it. In fact, the subscript of x doesn't get written out initially.
%%manim clttest --low_quality
class clttest(Scene):
def construct(self):
xj = TexMobject(
r"""\left[""",
r"""\sum_{j=0}^\infty x_j""",
r"""\right]"""
)
self.play(Write(xj[1]))
self.wait(2)
self.play(Write(xj[0]),
Write(xj[2]))
The problem lies with \sum I assume because running this works just fine
%%manim clttest --low_quality
class clttest(Scene):
def construct(self):
xj = TexMobject(
r"""\left[""",
r"""x_j""",
r"""\right]"""
)
self.play(Write(xj[1]))
self.wait(2)
self.play(Write(xj[0]),
Write(xj[2]))
How do i add additional letters. I think i have to change the tex.template.tex. but it doesnt work
I see an error in line image = ImageMobject("/content/manim/Pol/1.png")
. The same code works perfectly with command line !python3 -m manim example.py mainScene -r 1080,1920
.
/tmp/tmpl8hjzawx.py:15: UserWarning: Import from notebook: name already in the globals(), skipping
warn('Import from notebook: ' + name + ' already in the globals(), skipping')
Traceback (most recent call last):
File "/content/manim/manimlib/extract_scene.py", line 155, in main
scene = SceneClass(**scene_kwargs)
File "/content/manim/manimlib/scene/scene.py", line 53, in __init__
self.construct()
File "/tmp/tmpl8hjzawx.py", line 34, in construct
image = ImageMobject("/content/manim/Pol/1.png")
File "/content/manim/manimlib/mobject/types/image_mobject.py", line 56, in __init__
image = Image.open(path).convert(self.image_mode)
File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 2804, in open
init()
File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 2790, in _open_core
File "/usr/local/lib/python3.6/dist-packages/PIL/ImageFile.py", line 102, in __init__
self._open()
File "/usr/local/lib/python3.6/dist-packages/PIL/PngImagePlugin.py", line 579, in _open
self.size = self.png.im_size
AttributeError: can't set attribute
If you stop playback and try move frame by frame with arrows on the keyboard you will see duplicate frames. The same file in other player has no duplicates. I'm not sure is this a bug or not, but it's inconvenient.
I'm pretty new to the Jupyter Notebook/Book universe, so I'm sorry if this question seems silly.
I'm trying to integrate Manim animations into my Jupyter Book rendering my animations as gifs. But somehow I don't get an output when I open my build in Chrome. I just get the message:
<IPython.core.display.Image object>
I've tried to dig into different posts but nothing really seems to work. The funny thing is when I open my .ipynb file in jupyter-notebook and run my code-snip there is no problem. The problem occurs when I build my Jupyter Book.
This is the following code I'm able to execute in jupyter-notebook but somehow not when building the Jupyter Book:
`from manim import *
%%manim -v WARNING --progress_bar None -r 400,200 --format=gif --disable_caching HelloManim
class HelloManim(Scene):
def construct(self):
self.camera.background_color = "#ece6e2"
banner_large = ManimBanner(dark_theme=False).scale(0.7)
self.play(banner_large.create())
self.play(banner_large.expand())`
Has anyone else tried this and knows why this issue occur?
The problem is that base64coding videos will make the webpage slower and consume way more memory, but there is a better way, blobing the files.
Here is a google colab showing it off https://colab.research.google.com/drive/1FF6AHXu0L6nQw-LF8LymRotfcKfBI5Vh?usp=sharing
if you see the url of the video, you will see that it is a blob.
https://stackoverflow.com/questions/61982233/how-to-get-url-from-google-collab-file-inside-the-workspace/61984094#61984094
A SE question explaining the issue too.
Alternatively, allow a callback function for the url of the file once is completed, the callback will contain the custom code.
%%manim Shapes --base64 --low_quality --verbose
class Demo(Scene):
def construct(self):
text = Text('Hello, world!')
self.play(Write(text))
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
/tmp/tmpgj01amj5.py:15: UserWarning: Import from notebook: name already in the globals(), skipping
warn('Import from notebook: ' + name + ' already in the globals(), skipping')Shapes is not in the script
Traceback (most recent call last):
File "/content/manim/manimlib/extract_scene.py", line 155, in main
scene = SceneClass(**scene_kwargs)
File "/content/manim/manimlib/scene/scene.py", line 53, in init
self.construct()
File "/tmp/tmpgj01amj5.py", line 23, in construct
text = Text('Hello, world!')
TypeError: init() takes 1 positional argument but 2 were given
It works with command line:
!python3 -m manim example_scenes.py Demo -pl
Hi, I'm using jupyter_manim and it has issues in creating texobjects. I have already installed the latex distribution for my Linux operating system, but it's still showing Latex error converting to dvi. Please help me out.
Hi, I really like this project!
It would be great if %%manim
allowed output as GIF, so that when notebooks are being rendered in Github, the animations can be seen.
GIF is available in manim: https://github.com/3b1b/manim/pull/529/files
An example of where I'm trying to see it: https://github.com/NickLarsenNZ/notebooks/blob/650a92ef9611d5e70cee4cfff943b2b6cfc6408d/math/manim-walkthrough.ipynb (I've tried both default (mp4) and base64 video .output)
Hello,
I do not know if that is even possible, but it sure would be great to have a looping option for the video player.
Is it possible to see print
statements which were defined in def construct(self)
next to playback window in Jupyter?
This code works:
!python3 -m manim example_scenes.py WarpSquare -pl
This code works also in jupyter:
%%manim Shapes --base64 --low_quality
import numpy as np
class WarpSquare(Scene):
def construct(self):
square = Square()
self.play(ApplyPointwiseFunction(
lambda point: complex_to_R3(np.exp(R3_to_complex(point))),
square
))
self.wait()
But when
import numpy as np
was written in the cell before and already executed the code without this line can't find numpy:
%%manim Shapes --base64 --low_quality
class WarpSquare(Scene):
def construct(self):
square = Square()
self.play(ApplyPointwiseFunction(
lambda point: complex_to_R3(np.exp(R3_to_complex(point))),
square
))
self.wait()
Media will be written to ./media/. You can change this behavior with the --media_dir flag.
/usr/local/lib/python3.6/dist-packages/jupyter_manim/init.py:259: UserWarning: Could not find path in the manim output
warn('Could not find path in the manim output')
/tmp/tmp0wa7hz1o.py:15: UserWarning: Import from notebook: name already in the globals(), skipping
warn('Import from notebook: ' + name + ' already in the globals(), skipping')Shapes is not in the script
Traceback (most recent call last):
File "/content/manim/manimlib/extract_scene.py", line 155, in main
scene = SceneClass(**scene_kwargs)
File "/content/manim/manimlib/scene/scene.py", line 53, in init
self.construct()
File "/tmp/tmp0wa7hz1o.py", line 25, in construct
square
File "/content/manim/manimlib/scene/scene.py", line 406, in wrapper
func(self, *args, **kwargs)
File "/content/manim/manimlib/scene/scene.py", line 462, in play
self.begin_animations(animations)
File "/content/manim/manimlib/scene/scene.py", line 415, in begin_animations
animation.begin()
File "/content/manim/manimlib/animation/transform.py", line 46, in begin
self.target_mobject = self.create_target()
File "/content/manim/manimlib/animation/transform.py", line 182, in create_target
method.func(target, *args, **method_kwargs)
File "/content/manim/manimlib/mobject/types/vectorized_mobject.py", line 564, in apply_function
Mobject.apply_function(self, function)
File "/content/manim/manimlib/mobject/mobject.py", line 280, in apply_function
**kwargs
File "/content/manim/manimlib/mobject/mobject.py", line 360, in apply_points_function_about_point
mob.points = func(mob.points)
File "/content/manim/manimlib/mobject/mobject.py", line 279, in
lambda points: np.apply_along_axis(function, 1, points),
File "<array_function internals>", line 6, in apply_along_axis
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/shape_base.py", line 379, in apply_along_axis
for ind in inds:
File "/tmp/tmp0wa7hz1o.py", line 24, in
lambda point: complex_to_R3(np.exp(R3_to_complex(point))),
NameError: name 'np' is not defined
Why doesn't the cell with magic %%manim
find already imported libraries?
Hi, I try runing your git on colab. Then it shows this error. Can you show me how to fix it.
This is what I have on colab
###### cloning manim repo #######
!git clone https://github.com/3b1b/manim.git
###### installing requirements #####
%cd manim
#for fixing pycairo installing error: failed building wheel
!sudo apt install libcairo2-dev pkg-config python3-dev
!pip3 install -r requirements.txt
##### installing jupyter_manim #####
!pip3 install jupyter-manim
import jupyter_manim
%%manim Shapes --low_quality
from manimlib.imports import *
class Shapes(Scene):
def construct(self):
circle = Circle()
self.play(ShowCreation(circle))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.