OpenSource-Hub

manim

ライブラリ

3b1b/manim

精密な数学解説動画を作成するためのアニメーションエンジン。

概要

Manim は、正確な数学解説動画を制作するための Python アニメーションエンジンです。オブジェクトやアニメーションを定義するための直感的な構文を提供し、OpenGL と LaTeX をサポートすることで高品質な出力をレンダリングします。

README プレビュー

\n    \n        \n    \n\n\n[](https://pypi.org/project/manimgl/)\n[](http://choosealicense.com/licenses/mit/)\n[](https://www.reddit.com/r/manim/)\n[](https://discord.com/invite/bYCyhM9Kz2)\n[](https://3b1b.github.io/manim/)\n\nManim is an engine for precise programmatic animations, designed for creating explanatory math videos.\n\nNote, there are two versions of manim.  This repository began as a personal project by the author of [3Blue1Brown](https://www.3blue1brown.com/) for the purpose of animating those videos, with video-specific code available [here](https://github.com/3b1b/videos).  In 2020 a group of developers forked it into what is now the [community edition](https://github.com/ManimCommunity/manim/), with a goal of being more stable, better tested, quicker to respond to community contributions, and all around friendlier to get started with. See [this page](https://docs.manim.community/en/stable/faq/installation.html#different-versions) for more details.\n\n## Installation\n> [!Warning]\n> **WARNING:** These instructions are for ManimGL _only_. Trying to use these instructions to install [Manim Community/manim](https://github.com/ManimCommunity/manim) or instructions there to install this version will cause problems. You should first decide which version you wish to install, then only follow the instructions for your desired version.\n\n> [!Note]\n> **Note**: To install manim directly through pip, please pay attention to the name of the installed package. This repository is ManimGL of 3b1b. The package name is `manimgl` instead of `manim` or `manimlib`. Please use `pip install manimgl` to install the version in this repository.\n\nManim runs on Python 3.10 or higher.\n\nSystem requirements are [FFmpeg](https://ffmpeg.org/), [OpenGL](https://www.opengl.org/) and [LaTeX](https://www.latex-project.org) (optional, if you want to use LaTeX).\nFor Linux, [Pango](https://pango.org) along with its development headers are required. See instruction [here](https://

FAQ (5)

トラブル対応
pip install -e . で Manim をインストールした後に発生する "ModuleNotFoundError: No module named 'trimesh' or 'pywavefront'" エラーの修正方法

このエラーは、trimesh と pywavefront が requirements.txt には記載されていたものの、setup.cfg の install_requires に含まれていなかったため、editable install ではこれらがインストールされなかったことが原因で発生します。

暫定的な回避策:

# まず仮想環境を有効化してください
source venv/bin/activate        # macOS/Linux
venv\Scripts\activate.bat       # Windows コマンドプロンプト
.\venv\Scripts\Activate.ps1     # Windows PowerShell

# 不足している依存パッケージをインストール
pip install trimesh pywavefront

恒久的な修正: 両方のパッケージを setup.cfg の install_requires に追加してから、再インストールします:

pip install -e .

このパッケージングの問題はコミット 4cec571c0 で修正されています。そのコミットを含むバージョンに更新することでも解決できます。

参照 Issue #2459
トラブル対応
ManimでSVGMobjectを使ってSVGを読み込むと、SVGのストロークが失われるのはなぜですか?

Manim v1.7.2 では、SVGMobject の stroke_width のデフォルト値が 0.0 になっており、これにより SVG 内で定義されているストローク幅が上書きされます。回避策として、stroke_width=None を渡すと、SVG 自体のストローク幅が保持されます。

p = SVGMobject("Simple.svg", stroke_width=None)

恒久的な修正は、「Honor stroke widths declared in SVG files」という PR を含む Manim バージョンにアップグレードすることです。この PR により、解析されたパスごとのストローク幅が 0.0 にリセットされないように、デフォルトの動作が変更されます。

参照 Issue #2343
トラブル対応
Python 3.13でmanimglを実行した際に表示される'pkg_resources is deprecated as an API'警告を修正する方法

パッケージの __init__.py で、pkg_resources を最新の importlib.metadata API に置き換えます:

try:
    from importlib.metadata import version, PackageNotFoundError
except ImportError:  # Python < 3.8
    from importlib_metadata import version, PackageNotFoundError  # type: ignore

try:
    __version__ = version("manimgl")
except PackageNotFoundError:
    __version__ = "unknown"

古いコードを削除します:

import pkg_resources
__version__ = pkg_resources.get_distribution("manimgl").version

Python 3.8 より前のバージョンでは、pip install importlib-metadata でバックポートをインストールしてください。これにより、Python 3.13 以降での非推奨警告が解消されます。

参照 Issue #2388
トラブル対応
ManimでVectorFieldと一緒にrotate_vectorを使用した際に発生するValueError: shapes (N,2) and (3,3) not alignedを修正するにはどうすればよいですか?

これは、VectorField がすべてのサンプル点を (N, 2) のバッチ配列として関数に渡すのに対し、rotate_vector がそれに 3×3 の回転行列を掛けようとするために発生します。バッチ化された 2D 回転の修正を含む最新の master に Manim を更新してください:

pip install -U git+https://github.com/3b1b/manim.git

ローカルのクローンからインストールした場合:

git pull
pip install -e .

暫定的な回避策として、rotate_vector を呼び出す代わりに、2D 回転を直接適用してください:

def rotate_2d(vector, angle):
    c, s = np.cos(angle), np.sin(angle)
    rotation = np.array([
        [c, -s],
        [s,  c],
    ])
    return np.asarray(vector) @ rotation.T

def curl_func(p):
    return rotate_2d(p / 3, PI / 2)

field_curl = VectorField(curl_func, axes)

これは、単一のベクトルと (N, 2) の形状を持つバッチ配列の両方で動作します。

参照 Issue #2336
トラブル対応
Python 3.8 に manim をインストールする際に 'No matching distribution found for ipython>=8.18.0' というエラーが出る場合、どう修正すればよいですか?

インストールが失敗するのは、ipython>=8.18.0 が Python 3.9 以降を必要とするためです。サポートされている Python バージョンで Conda 環境を作成してください。manimlib も Python 3.9 ではインポートに失敗する可能性があるため、Python 3.10 を使用してください:

conda create -n manim python=3.10
conda activate manim
pip install -e .

古い環境がすでに存在する場合は、まず conda env remove -n manim で削除してから、再作成してください。

参照 Issue #2405