LoginSignup
2
0

【解決策】Google Colabでmoviepyを使用時のImageMagickエラー: 正しいインストール手順

Last updated at Posted at 2023-12-06

moviepyで動画に字幕を入れようとしたとき、
ImageMagickのエラーで躓いたためメモとして残しておきます。

該当コード

txt_clip = TextClip("テキスト")

エラー内容

OSError: MoviePy Error: creation of None failed because of the following error:

[Errno 2] No such file or directory: 'C:\\\\Program Files\\\\ImageMagick-7.0.8-Q16\\\\magick.exe'.

.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect

解決策

Google Colabのランタイムを再起動し、以下のコードを実行すると無事終わりました。

apt update
apt install imagemagick
apt install ffmpeg
pip3 install moviepy
sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml  

ポイント

  • moviepy[optional]としてインストールすることで、ImageMagickを含むすべての依存関係を一括でインストールできます。
  • ffmpegimagemagickmoviepyよりも前にインストールする必要があります。
  • '/<policy domain="path" rights="none" pattern="@\*"/d'というポリシーを削除することで、エラーを回避できます。

最初は日本語で調べていましたが、なかなか解決できなかったため
GithubのIssueの解決策をひたすら試し、該当コメントによってようやく解決しました。
感謝。

参考

2
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
2
0