0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【未解決】3blue1brownのチュートリアル動画を再現するためにテキトーに環境構築したら沼った話

Posted at

仮想環境

当方のiMacでなぜかpipが呼べないという信じられない事態に陥っていたので、venvで構築しています。

本筋に関係ない仮想環境導入までの話

仮想環境に乗り換えるまでの悪あがき

% pip install manimgl
zsh: command not found: pip

念の為pythonが入っているか確認。

% brew install python3
==> Auto-updating Homebrew...
(中略)
Error: No such file or directory @ rb_check_realpath_internal - /usr/local/Cellar/julia/1.11.2

どこかで見たget-pip.pyを入れる手法で解決を試みる。

% python3 get-pip.py
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a Python library that isn't in Homebrew,
    use a virtual environment:
    
    python3 -m venv path/to/venv
    source path/to/venv/bin/activate
    python3 -m pip install xyz
    
    If you wish to install a Python application that isn't in Homebrew,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. You can install pipx with
    
    brew install pipx
    
    You may restore the old behavior of pip by passing
    the '--break-system-packages' flag to pip, or by adding
    'break-system-packages = true' to your pip.conf file. The latter
    will permanently disable this error.
    
    If you disable this error, we STRONGLY recommend that you additionally
    pass the '--user' flag to pip, or set 'user = true' in your pip.conf
    file. Failure to do this can result in a broken Homebrew installation.
......

このあとpipxを使ってみたが、ダウンロードはできた素ぶりを見せるものの、結局manimglを読んでも返事がない。

仮想環境に乗り換え

venvとか今までおまじないだとしか思っておらず、まともに触ったことがなかったので、ここで克服してみる。
参考:https://qiita.com/shun_sakamoto/items/7944d0ac4d30edf91fde

  1. 作業ディレクトリに移動
  2. python3 -m venv venvで仮想環境を新規構築
  3. . venv/bin/activate
  4. pip3 install manimgl

余談ここまで

仮想環境上での格闘記録

ファイルをtutorial.pyとして実行してみる。
ModuleNotFoundError: No module named 'manim_imports_ext'とかいうエラーが出てきた。
調べてみるとmanim_imports_exthttps://github.com/3b1b/videos/blob/master/manim_imports_ext.py にある形で書かれていて、別に配布しているものでもなさそう。1

ワーキングディレクトリにmanim_imports_ext.pyを作成。

manim_imports_ext.py
from manimlib import *
from manimlib.mobject.svg.old_tex_mobject import *

from custom.backdrops import *
from custom.banner import *
from custom.characters.pi_creature import *
from custom.characters.pi_creature_animations import *
from custom.characters.pi_creature_scene import *
from custom.deprecated import *
from custom.drawings import *
from custom.end_screen import *
from custom.filler import *
from custom.logo import *
from custom.opening_quote import *

これで回してみよう。

python3 tutorial.py
Traceback (most recent call last):
(中略)
ModuleNotFoundError: No module named 'pkg_resources'

今度はhttps://qiita.com/HidKamiya/items/619ca56cee9a5005d5c4 にしたがって。

% pip install --upgrade setuptools
Collecting setuptools
  Using cached setuptools-75.6.0-py3-none-any.whl.metadata (6.7 kB)
Using cached setuptools-75.6.0-py3-none-any.whl (1.2 MB)
Installing collected packages: setuptools
Successfully installed setuptools-75.6.0
% python3 tutorial.py
Traceback (most recent call last):
(中略)
ModuleNotFoundError: No module named 'pyrr'

めげない、しょげない、泣いちゃだめ〜

% pip3 install pyrr
Successfully installed multipledispatch-1.0.0 pyrr-0.10.3
% python3 tutorial.py             
Traceback (most recent call last):
(中略)
ModuleNotFoundError: No module named 'audioop'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
(中略)
ModuleNotFoundError: No module named 'pyaudioop'
% pip3 install pyaudioop
ERROR: Could not find a version that satisfies the requirement pyaudioop (from versions: none)
ERROR: No matching distribution found for pyaudioop

なんでないんや。
audioopなんて削除されとるぞ。https://docs.python.org/ja/3.11/library/audioop.html
ダウングレードしないといけないらしい。
流石にめんどい。

  1. https://stackoverflow.com/questions/74747935/hello-guys-i-am-using-manim-library-for-animations で言ってた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?