@Tonoyamaさんの記事をみて、ManimをMacbookに入れてみました。
・ @Tonoyamaさん Pythonで数式・グラフのアニメを描ける「Manim」
作成したMP4ファイル(1)
作成したMP4ファイル(2)
#実行したサンプルコード(1)
・ CAFFAE How to Install Manim for Mac
Terminal
% cd Desktop/manim
manim % ls
Dockerfile docs manim.py setup.cfg
LICENSE environment.yml manim_docker_diagram.png setup.py
README.md example_scenes.py manimlib stage_scenes.py
__pycache__ from_3b1b media travis
docker-compose.yml logo requirements.txt venv
manim %
manim % virtualenv venv
manim % source venv/bin/activate
manim % pip3 install sox ffmpeg latex pycairo
(venv) manim % ls
Dockerfile docker-compose.yml from_3b1b manimlib stage_scenes.py
LICENSE docs logo requirements.txt travis
README.md environment.yml manim.py setup.cfg venv
__pycache__ example_scenes.py manim_docker_diagram.png setup.py
manim % cat requirements.txt
argparse
colour
numpy
Pillow
progressbar
scipy
tqdm
opencv-python
pycairo
pydub
pygments
pyreadline; sys_platform == 'win32'
manim % pip3 install -r requirements.txt
Terminal
(venv) manim % python3 -m manim example_scenes.py
Media will be written to /Users/ocean/Desktop/manim/media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff
Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 2
File ready at /Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/SquareToCircle.mp4
Played 3 animations
(venv) manim %
(venv) manim % ls /Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/SquareToCircle.mp4
/Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/SquareToCircle.mp4
(venv) manim %
% ffmpeg -i
manim % deactivate
manin % /Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/SquareToCircle.mp4 -r 50 SquareToCircle.gif
Desktop % ls *.gif
SquareToCircle.gif
manim %
#吐き出されたMP4ファイルを確認
#実行したサンプルコード(2)
Terminal
```bash:Terminal
manim % python3 -m manim example_scenes.py
Media will be written to /Users/ocean/Desktop/manim/media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff
Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 3
Writing "+" to /Users/ocean/Desktop/manim/media/Tex/701bbfb7cb8d210c.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Writing "0" to /Users/ocean/Desktop/manim/media/Tex/0f3ccd5562128687.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Writing "." to /Users/ocean/Desktop/manim/media/Tex/0791945beca35ac3.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Writing "\dots" to /Users/ocean/Desktop/manim/media/Tex/56ff6ce3bda9aed7.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Writing "2" to /Users/ocean/Desktop/manim/media/Tex/3d052336c1e3bf0f.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Writing "5" to /Users/ocean/Desktop/manim/media/Tex/957bc2d10c45e9f8.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Animation 0: MoveToTargetSquare: 0%| | 0/300 [00:00<?, ?it/s]Writing "4" to /Users/ocean/Desktop/manim/media/Tex/0079e539c2bb727b.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Writing "9" to /Users/ocean/Desktop/manim/media/Tex/fcf5bb509920cd38.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Writing "8" to /Users/ocean/Desktop/manim/media/Tex/d381d5de7709b238.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Animation 0: MoveToTargetSquare: 1%|▌ | 2/300 [00:03<07:38, 1.54s/it]Writing "3" to /Users/ocean/Desktop/manim/media/Tex/56d3dc830a188b52.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Animation 0: MoveToTargetSquare: 1%|█ | 4/300 [00:04<06:06, 1.24s/it]Writing "7" to /Users/ocean/Desktop/manim/media/Tex/c2a7e295cf7ba1eb.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Animation 0: MoveToTargetSquare: 2%|█▋ | 6/300 [00:05<05:02, 1.03s/it]Writing "6" to /Users/ocean/Desktop/manim/media/Tex/be2011bd7d40b30b.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Animation 0: MoveToTargetSquare: 6%|████▉ | 18/300 [00:06<01:29, 3.15it/s]Writing "1" to /Users/ocean/Desktop/manim/media/Tex/9f555629e552b431.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
Animation 0: MoveToTargetSquare: 25%|████████████████████▊ | 76/300 [00:10<00:10, 22.35it/s]Writing "-" to /Users/ocean/Desktop/manim/media/Tex/5ae072d0e0fd537e.tex
latex: major issue: So far, you have not checked for MiKTeX updates.
File ready at /Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4
Played 2 animations
%
```
```bash:Terminal
% ls /Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4
/Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4
%
```
![スクリーンショット 2020-12-21 3.02.23.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/cfa82ec6-b6ef-a779-739e-91ae74850c57.png)
```bash:Terminal
manim % ffmpeg -i /Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4 -r 50 UpdatersExample.gif
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.27)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/ocean/Desktop/manim/media/videos/example_scenes/1440p60/UpdatersExample.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:00:06.00, start: 0.000000, bitrate: 325 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2560x1440, 318 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> gif (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7f93cf049000] No accelerated colorspace conversion found from yuv420p to bgr8.
Output #0, gif, to 'UpdatersExample.gif':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Stream #0:0(und): Video: gif, bgr8, 2560x1440, q=2-31, 200 kb/s, 50 fps, 100 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.91.100 gif
frame= 301 fps=106 q=-0.0 Lsize= 1316kB time=00:00:06.01 bitrate=1794.2kbits/s dup=0 drop=59 speed=2.12x
video:1316kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.001484%
manim %
manim % ls *.gif
UpdatersExample.gif
manim %
```
# 環境構築
・ [Manim Docs » Installation » Mac](https://azarzadavila-manim.readthedocs.io/en/latest/installation/mac.html)
・ [CAFFAE How to Install Manim for Mac](https://caffae.wordpress.com/2019/09/01/how-to-install-manim-for-mac/)
```bash:Terminal
% brew install cairo
% brew install sox
% brew cask install mactex
% pip install manimlib
% pip install sox
% pip install ffmpeg
% pip install manim
% cd Desktop
Desktop % git clone https://github.com/3b1b/manim.git
Desktop % cd manim
manim % ls
Dockerfile docker-compose.yml example_scenes.py manim.py requirements.txt stage_scenes.py
LICENSE docs from_3b1b manim_docker_diagram.png setup.cfg travis
README.md environment.yml logo manimlib setup.py
manim %
```
・ [MacBook Pro(macOS Sierra)にTeXを導入](https://kakubari-ryusei.hatenablog.com/entry/2017/07/03/193907)
![スクリーンショット 2020-12-21 2.25.50.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/da52434b-7f78-dee8-e8f8-8679c146d2a2.png)
![スクリーンショット 2020-12-21 2.27.44.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/40d884cf-0634-10d9-aadc-9abf73704547.png)
![スクリーンショット 2020-12-21 2.27.56.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/6d751131-cd89-1922-7974-7741f1106fd7.png)
![スクリーンショット 2020-12-21 2.28.12.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/8dd4730e-6dd7-e1bf-0be3-6fa57be6a27d.png)
![スクリーンショット 2020-12-21 2.29.34.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/1fa45d1c-6efc-f082-a220-f6863de13a3a.png)
![スクリーンショット 2020-12-21 2.29.46.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/024b29aa-305f-1528-c581-1aab2d6916ca.png)
![スクリーンショット 2020-12-21 2.30.29.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/ba8fecae-b3c3-9abf-e67f-30df17b50a26.png)
![スクリーンショット 2020-12-21 2.30.53.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/32a1ccb1-5ca0-6346-6fa0-9d781b7dd3b1.png)
![スクリーンショット 2020-12-21 2.31.04.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/54bcc94c-d7a1-48a5-2854-67515f87f8e8.png)
__latexコマンドが認識された。__
```bash:Terminal
% echo export 'PATH=~/bin:$PATH'>> ~/.bash_profile
% source ~/.bash_profile
% latex
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.12)
**^Z
zsh: suspended latex
% latex -version
MiKTeX-pdfTeX 4.1 (MiKTeX 20.12)
© 1982 D. E. Knuth, © 1996-2020 Hàn Thế Thành
TeX is a trademark of the American Mathematical Society.
using bzip2 version 1.0.6, 6-Sept-2010
compiled with curl version 7.64.1; using libcurl/7.64.1 SecureTransport (LibreSSL/2.8.3) zlib/1.2.11 nghttp2/1.39.2
compiled with expat version 2.2.8; using expat_2.2.8
compiled with jpeg version 9.4
compiled with liblzma version 50020052; using 50000052
compiled with libpng version 1.6.37; using 1.6.37
compiled with MiKTeX Application Framework version 4.0; using 4.0
compiled with MiKTeX Core version 4.3; using 4.3
compiled with MiKTeX Archive Extractor version 4.0; using 4.0
compiled with MiKTeX Package Manager version 4.1; using 4.1
compiled with openssl version OpenSSL 1.1.1i 8 Dec 2020; using OpenSSL 1.1.1i 8 Dec 2020
compiled with uriparser version 0.9.4
compiled with xpdf version 4.02
compiled with zlib version 1.2.11; using 1.2.11
latex: major issue: So far, you have not checked for MiKTeX updates.
%
% pip3 install manim
```
#実行ファイルの中身
```bash:Terminal
(venv) manim % cat example_scenes.py
#!/usr/bin/env python
from manimlib.imports import *
# To watch one of these scenes, run the following:
# python -m manim example_scenes.py SquareToCircle -pl
#
# Use the flag -l for a faster rendering at a lower
# quality.
# Use -s to skip to the end and just save the final frame
# Use the -p to have the animation (or image, if -s was
# used) pop up once done.
# Use -n <number> to skip ahead to the n'th animation of a scene.
# Use -r <number> to specify a resolution (for example, -r 1080
# for a 1920x1080 video)
class OpeningManimExample(Scene):
def construct(self):
title = TextMobject("This is some \\LaTeX")
basel = TexMobject(
"\\sum_{n=1}^\\infty "
"\\frac{1}{n^2} = \\frac{\\pi^2}{6}"
)
VGroup(title, basel).arrange(DOWN)
self.play(
Write(title),
FadeInFrom(basel, UP),
)
self.wait()
transform_title = TextMobject("That was a transform")
transform_title.to_corner(UP + LEFT)
self.play(
Transform(title, transform_title),
LaggedStart(*map(FadeOutAndShiftDown, basel)),
)
self.wait()
grid = NumberPlane()
grid_title = TextMobject("This is a grid")
grid_title.scale(1.5)
grid_title.move_to(transform_title)
self.add(grid, grid_title) # Make sure title is on top of grid
self.play(
FadeOut(title),
FadeInFromDown(grid_title),
ShowCreation(grid, run_time=3, lag_ratio=0.1),
)
self.wait()
grid_transform_title = TextMobject(
"That was a non-linear function \\\\"
"applied to the grid"
)
grid_transform_title.move_to(grid_title, UL)
grid.prepare_for_nonlinear_transform()
self.play(
grid.apply_function,
lambda p: p + np.array([
np.sin(p[1]),
np.sin(p[0]),
0,
]),
run_time=3,
)
self.wait()
self.play(
Transform(grid_title, grid_transform_title)
)
self.wait()
class SquareToCircle(Scene):
def construct(self):
circle = Circle()
square = Square()
square.flip(RIGHT)
square.rotate(-3 * TAU / 8)
circle.set_fill(PINK, opacity=0.5)
self.play(ShowCreation(square))
self.play(Transform(square, circle))
self.play(FadeOut(square))
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()
class WriteStuff(Scene):
def construct(self):
example_text = TextMobject(
"This is some text",
tex_to_color_map={"text": YELLOW}
)
example_tex = TexMobject(
"\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}",
)
group = VGroup(example_text, example_tex)
group.arrange(DOWN)
group.set_width(FRAME_WIDTH - 2 * LARGE_BUFF)
self.play(Write(example_text))
self.play(Write(example_tex))
self.wait()
class UpdatersExample(Scene):
def construct(self):
decimal = DecimalNumber(
0,
show_ellipsis=True,
num_decimal_places=3,
include_sign=True,
)
square = Square().to_edge(UP)
decimal.add_updater(lambda d: d.next_to(square, RIGHT))
decimal.add_updater(lambda d: d.set_value(square.get_center()[1]))
self.add(square, decimal)
self.play(
square.to_edge, DOWN,
rate_func=there_and_back,
run_time=5,
)
self.wait()
# See old_projects folder for many, many more
(venv) manim %
```
#サンプルコードの1は失敗
```bash:Terminal
% python3 -m manim example_scenes.py
Media will be written to /Users/ocean/Desktop/manim/media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff
Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 1
qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "/Users/ocean/.pyenv/versions/3.6.3/lib/python3.6/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: cocoa.
sh: line 1: 3788 Abort trap: 6 latex -interaction=batchmode -halt-on-error -output-directory="/Users/ocean/Desktop/manim/media/Tex" "/Users/ocean/Desktop/manim/media/Tex/664e80e8d8d98482.tex" > /dev/null
Traceback (most recent call last):
File "/Users/ocean/Desktop/manim/manimlib/extract_scene.py", line 155, in main
scene = SceneClass(**scene_kwargs)
File "/Users/ocean/Desktop/manim/manimlib/scene/scene.py", line 75, in __init__
self.construct()
File "example_scenes.py", line 20, in construct
title = TextMobject("This is some \\LaTeX")
File "/Users/ocean/Desktop/manim/manimlib/mobject/svg/tex_mobject.py", line 148, in __init__
self, self.arg_separator.join(tex_strings), **kwargs
File "/Users/ocean/Desktop/manim/manimlib/mobject/svg/tex_mobject.py", line 44, in __init__
self.template_tex_file_body
File "/Users/ocean/Desktop/manim/manimlib/utils/tex_file_writing.py", line 21, in tex_to_svg_file
dvi_file = tex_to_dvi(tex_file)
File "/Users/ocean/Desktop/manim/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: /Users/ocean/Desktop/manim/media/Tex/664e80e8d8d98482.log
$
```
・ https://qiita.com/jmtsn/items/aa73d837b3a8d4158885
> 結局、opencv-python 4.1系にダウングレードしたら解決した。
>
>pip3 install opencv-python==4.1.2.30
>pip3 install opencv-contrib-python==4.1.2.30
```bash:Teminal
% pip3 install opencv-python==4.1.2.30
Collecting opencv-python==4.1.2.30
Downloading opencv_python-4.1.2.30-cp36-cp36m-macosx_10_9_x86_64.whl (45.2 MB)
|████████████████████████████████| 45.2 MB 10.5 MB/s
Requirement already satisfied: numpy>=1.11.3 in /Users/ocean/.pyenv/versions/3.6.3/lib/python3.6/site-packages (from opencv-python==4.1.2.30) (1.19.4)
Installing collected packages: opencv-python
Attempting uninstall: opencv-python
Found existing installation: opencv-python 4.4.0.46
Uninstalling opencv-python-4.4.0.46:
Successfully uninstalled opencv-python-4.4.0.46
Successfully installed opencv-python-4.1.2.30
%
% pip3 install opencv-contrib-python==4.1.2.30
Collecting opencv-contrib-python==4.1.2.30
Downloading opencv_contrib_python-4.1.2.30-cp36-cp36m-macosx_10_9_x86_64.whl (55.1 MB)
|████████████████████████████████| 55.1 MB 16.6 MB/s
Requirement already satisfied: numpy>=1.11.3 in /Users/ocean/.pyenv/versions/3.6.3/lib/python3.6/site-packages (from opencv-contrib-python==4.1.2.30) (1.19.4)
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-4.1.2.30
%
```
```
% python3 -m manim example_scenes.py
Media will be written to /Users/ocean/Desktop/manim/media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff
Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 1
```
####以下、いろいろ入れた。
![スクリーンショット 2020-12-21 2.56.24.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/20c7e4ef-7058-4a4e-9fef-c667ed4b59c3.png)
![スクリーンショット 2020-12-21 2.56.54.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/94c15d45-cbb4-2d80-e634-f53e5fd03745.png)
![スクリーンショット 2020-12-21 2.57.06.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/862466/1f4d68aa-3418-cd7c-4b91-719785a37b0a.png)
( ・・・ 省略 ・・・ )
####今度は、IndexError: list index out of rangeが起きた。
```
% python3 -m manim example_scenes.py
Media will be written to /Users/ocean/Desktop/manim/media/. You can change this behavior with the --media_dir flag.
1: OpeningManimExample
2: SquareToCircle
3: UpdatersExample
4: WarpSquare
5: WriteStuff
Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s): 1
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-84 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-104 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-105 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-115 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-111 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-109 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-101 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-76 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g0-65 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-69 not recognized
warnings.warn("%s not recognized" % ref)
/Users/ocean/Desktop/manim/manimlib/mobject/svg/svg_mobject.py:125: UserWarning: g1-88 not recognized
warnings.warn("%s not recognized" % ref)
Traceback (most recent call last):
File "/Users/ocean/Desktop/manim/manimlib/extract_scene.py", line 155, in main
scene = SceneClass(**scene_kwargs)
File "/Users/ocean/Desktop/manim/manimlib/scene/scene.py", line 75, in __init__
self.construct()
File "example_scenes.py", line 20, in construct
title = TextMobject("This is some \\LaTeX")
File "/Users/ocean/Desktop/manim/manimlib/mobject/svg/tex_mobject.py", line 150, in __init__
self.break_up_by_substrings()
File "/Users/ocean/Desktop/manim/manimlib/mobject/svg/tex_mobject.py", line 190, in break_up_by_substrings
sub_tex_mob.move_to(self.submobjects[last_submob_index], RIGHT)
IndexError: list index out of range
manim %
```
##*@Tonoyama*さんのコードを*text.py*で保存して実行したところ、エラーになった。
```
manim % cat test.py
from manim import *
class HelloWorld(Scene):
def construct(self):
#######Code#######
# テキストを定義
first_text = Text("Hello, World!")
# テキストを表示
self.wait(1)
self.play(Write(first_text))
self.wait(1)
# テキスト2つ分アップ
self.play(ApplyMethod(first_text.shift,2*UP))
self.wait(1)
math_text=MathTex(
"\\frac{d}{dx}f(x)g(x)=","f(x)\\frac{d}{dx}g(x)","+",
"g(x)\\frac{d}{dx}f(x)"
)
# 数式を表示
self.play(Write(math_text))
framebox1 = SurroundingRectangle(math_text[1], buff = .1)
framebox2 = SurroundingRectangle(math_text[3], buff = .1)
self.play(
ShowCreation(framebox1),
)
self.wait()
# manim.animation.transform
self.play(
ReplacementTransform(framebox1,framebox2),
)
self.wait()
manim %
```
```bash:Terminal
manim % manim test.py HelloWorld -ql -i
pyenv: manim: command not found
The `manim' command exists in these Python versions:
3.9.0
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
manim % manim
pyenv: manim: command not found
The `manim' command exists in these Python versions:
3.9.0
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
manim % python3 -m manim test.py HelloWorld -ql -i
Traceback (most recent call last):
File "/Users/ocean/.pyenv/versions/3.6.3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Users/ocean/.pyenv/versions/3.6.3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/ocean/Desktop/manim/manim.py", line 5, in <module>
manimlib.main()
File "/Users/ocean/Desktop/manim/manimlib/__init__.py", line 9, in main
config = manimlib.config.get_configuration(args)
File "/Users/ocean/Desktop/manim/manimlib/config.py", line 155, in get_configuration
module = get_module(args.file)
File "/Users/ocean/Desktop/manim/manimlib/config.py", line 150, in get_module
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "test.py", line 3, in <module>
class HelloWorld(Scene):
NameError: name 'Scene' is not defined
manim %
```
#####*git clone*した時に、*manim.py*からは、*Scene*クラスを読み込めていない。
```bash
manim % cat manim.py
#!/usr/bin/env python
import manimlib
if __name__ == "__main__":
manimlib.main()
manim % cat manimlib.py
cat: manimlib.py: No such file or directory
manim %
```
#####*Scene*クラスが定義されていたのは、以下の*scene.py*だった。
https://github.com/3b1b/manim/blob/master/manimlib/scene/scene.py
github(manim/manimlib/scene/scene.py)から class Sceneが定義されたscene.pyをカレンとディレクトリに入れる。
```
manim % vi scene.py
manim % cat scene.py
import inspect
import random
import warnings
import platform
from tqdm import tqdm as ProgressDisplay
import numpy as np
from manimlib.animation.animation import Animation
from manimlib.animation.transform import MoveToTarget, ApplyMethod
from manimlib.camera.camera import Camera
from manimlib.constants import *
from manimlib.container.container import Container
from manimlib.mobject.mobject import Mobject
from manimlib.scene.scene_file_writer import SceneFileWriter
from manimlib.utils.iterables import list_update
class Scene(Container):
"""
A Scene can be thought of as the Canvas of your animation.
All of your own named Scenes will be subclasses of this Scene, or
other named scenes.
Use a construct() function to tell Manim what should go on in the Scene.
E.G:
class MyScene(Scene):
def construct(self):
self.play(
Write(Text("Hello World!"))
)
( ・・・省略・・・ )
def show_frame(self):
"""
Opens the current frame in the Default Image Viewer
of your system.
"""
self.update_frame(ignore_skipping=True)
self.get_image().show()
class EndSceneEarlyException(Exception):
manim %
```
#####*test.py*から*scene.py*をimportするように変更
```bash:Terminal
manim % head test.py
#from manim import *
from scene import *
class HelloWorld(Scene):
def construct(self):
#######Code#######
# テキストを定義
first_text = Text("Hello, World!")
# テキストを表示
manim %
```
#今度は別のエラー
```
manim % python3 -m manim test.py HelloWorld -ql -i
Media will be written to /Users/ocean/Desktop/manim/media/. You can change this behavior with the --media_dir flag.
There are no scenes inside that module
manim %
```
# 同じエラーが報告されている。
・ https://github.com/3b1b/manim/issues/1228
> zhangj563 commented on 15 Sep
[09/15/20 04:18:10] ERROR main.py:83
There are no scenes inside that module
>
>@huguesdevimeux
huguesdevimeux commented on 17 Sep
Without the code we can't really do anything.
It's most likely that you forget to make your scene inherit from Scene
###ちゃんと動いた*example_scenes.py*と同じimport文に変えてみる。
```bash:Terminal
manim % cat example_scenes.py
#!/usr/bin/env python
from manimlib.imports import *
# To watch one of these scenes, run the following:
# python -m manim example_scenes.py SquareToCircle -pl
#
# Use the flag -l for a faster rendering at a lower
# quality.
# Use -s to skip to the end and just save the final frame
# Use the -p to have the animation (or image, if -s was
# used) pop up once done.
# Use -n <number> to skip ahead to the n'th animation of a scene.
# Use -r <number> to specify a resolution (for example, -r 1080
# for a 1920x1080 video)
class OpeningManimExample(Scene):
def construct(self):
title = TextMobject("This is some \\LaTeX")
basel = TexMobject(
"\\sum_{n=1}^\\infty "
"\\frac{1}{n^2} = \\frac{\\pi^2}{6}"
)
VGroup(title, basel).arrange(DOWN)
self.play(
Write(title),
FadeInFrom(basel, UP),
)
self.wait()
transform_title = TextMobject("That was a transform")
transform_title.to_corner(UP + LEFT)
self.play(
Transform(title, transform_title),
LaggedStart(*map(FadeOutAndShiftDown, basel)),
)
self.wait()
grid = NumberPlane()
grid_title = TextMobject("This is a grid")
grid_title.scale(1.5)
grid_title.move_to(transform_title)
self.add(grid, grid_title) # Make sure title is on top of grid
self.play(
FadeOut(title),
FadeInFromDown(grid_title),
ShowCreation(grid, run_time=3, lag_ratio=0.1),
)
self.wait()
grid_transform_title = TextMobject(
"That was a non-linear function \\\\"
"applied to the grid"
)
grid_transform_title.move_to(grid_title, UL)
grid.prepare_for_nonlinear_transform()
self.play(
grid.apply_function,
lambda p: p + np.array([
np.sin(p[1]),
np.sin(p[0]),
0,
]),
run_time=3,
)
self.wait()
self.play(
Transform(grid_title, grid_transform_title)
)
self.wait()
class SquareToCircle(Scene):
def construct(self):
circle = Circle()
square = Square()
square.flip(RIGHT)
square.rotate(-3 * TAU / 8)
circle.set_fill(PINK, opacity=0.5)
self.play(ShowCreation(square))
self.play(Transform(square, circle))
self.play(FadeOut(square))
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()
class WriteStuff(Scene):
def construct(self):
example_text = TextMobject(
"This is some text",
tex_to_color_map={"text": YELLOW}
)
example_tex = TexMobject(
"\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}",
)
group = VGroup(example_text, example_tex)
group.arrange(DOWN)
group.set_width(FRAME_WIDTH - 2 * LARGE_BUFF)
self.play(Write(example_text))
self.play(Write(example_tex))
self.wait()
class UpdatersExample(Scene):
def construct(self):
decimal = DecimalNumber(
0,
show_ellipsis=True,
num_decimal_places=3,
include_sign=True,
)
square = Square().to_edge(UP)
decimal.add_updater(lambda d: d.next_to(square, RIGHT))
decimal.add_updater(lambda d: d.set_value(square.get_center()[1]))
self.add(square, decimal)
self.play(
square.to_edge, DOWN,
rate_func=there_and_back,
run_time=5,
)
self.wait()
# See old_projects folder for many, many more
manim %
```
```bash:Terminal
manim % vi test.py
manim % head test.py
#from manim import *
from manimlib.imports import *
class HelloWorld(Scene):
def construct(self):
#######Code#######
# テキストを定義
first_text = Text("Hello, World!")
# テキストを表示
manim %
```
```
manim % python3 -m manim test.py HelloWorld -ql -i
Media will be written to /Users/ocean/Desktop/manim/media/. You can change this behavior with the --media_dir flag.
Warning:
You haven't set font.
If you are not using English, this may cause text rendering problem.
You set font like:
text = Text('your text', font='your font')
or:
class MyText(Text):
CONFIG = {
'font': 'My Font'
}
Traceback (most recent call last):
File "/Users/ocean/Desktop/manim/manimlib/extract_scene.py", line 155, in main
scene = SceneClass(**scene_kwargs)
File "/Users/ocean/Desktop/manim/manimlib/scene/scene.py", line 75, in __init__
self.construct()
File "test.py", line 18, in construct
math_text=MathTex(
NameError: name 'MathTex' is not defined
manim %
```
###調べたところ、Macにmathtexは入れられないらしい。
###@Tonoyamaさんは、Ubuntu環境を使っていた。Ubuntuにはmathtexをインストールできる。
#Mac用のTutorialにあるサンプルコードも実行エラー
・ http://bhowell4.com/manic-install-tutorial-for-mac/
```
python3 extract_scene.py example_scenes.py WriteStuff -pl
```
extract_scene.py は、./manimlib配下にある。以下で実行できる。
```
python3 ./manimlib/extract_scene.py example_scenes.py SquareToCircle -pl
```
エラーになった。
```
manim% python3 ./manimlib/extract_scene.py example_scenes.py SquareToCircle -pl
Traceback (most recent call last):
File "./manimlib/extract_scene.py", line 168, in <module>
main()
TypeError: main() missing 1 required positional argument: 'config'
manim %
```
###このエラーも報告がある。
・ https://github.com/3b1b/manim/issues/758