简体   繁体   English

Matplotlib-Animation “没有可用的 MovieWriters”

[英]Matplotlib-Animation "No MovieWriters Available"

Under Linux, I've been checking out matplotlib's animation class, and it seems to work except that I cant initialise the movie writer to write out the movie.在 Linux 下,我一直在检查 matplotlib 的 animation class,除了我无法初始化电影编写器来写出电影外,它似乎可以工作。

Using either of the examples:使用任一示例:

results in the error " RuntimeError: No MovieWriters available! "导致错误“ RuntimeError: No MovieWriters available!

Im using matplotlib version 1.3.x and have installed (hopefully) all the codecs.我正在使用 matplotlib 版本 1.3.x 并已安装(希望)所有编解码器。

Can someone please suggest as to why I get this error?有人可以建议我为什么会收到此错误吗? If its a codecs issue, which codecs (+versions) should I install?如果是编解码器问题,我应该安装哪些编解码器(+版本)? If its something else that's broken, is there an alternative for creating animations in python?如果它的其他东西坏了,是否有在 python 中创建动画的替代方法?

For fellow googlers using Anaconda, install the ffmpeg package:对于使用 Anaconda 的谷歌员工,请安装ffmpeg包:

conda install -c conda-forge ffmpeg

This works on Windows too.这也适用于 Windows。

(Original answer used menpo package owner but as mentioned by @harsh their version is a little behind at time of writing) (原始答案使用menpo包所有者,但正如@harsh 所提到的,在撰写本文时,他们的版本有点落后)

Had the same problem....managed to get it to work after a little while.遇到了同样的问题....过了一会儿设法让它工作。

Thing to do is follow instructions on installing FFmpeg - which is (at least on windows) a bundle of executables you need to set a path to in your environment variables要做的是按照安装 FFmpeg 的说明进行操作 - 这是(至少在 Windows 上)您需要在环境变量中设置路径的一组可执行文件

http://www.wikihow.com/Install-FFmpeg-on-Windows http://www.wikihow.com/Install-FFmpeg-on-Windows

Download from ffmpeg.org从 ffmpeg.org 下载

Hope this helps someone - even after a while after the question - good luck希望这对某人有所帮助 - 即使在问题过后一段时间 - 祝你好运

I know this question is about Linux, but in case someone stumbles on this problem on Mac like I did here is the solution for that.我知道这个问题是关于 Linux 的,但是如果有人像我在这里那样在 Mac 上偶然发现这个问题,那么解决方案就是解决这个问题。 I had the exact same problem on Mac because ffmpeg is not installed by default apparently, and so I could solve it using:我在 Mac 上遇到了完全相同的问题,因为ffmpeg显然没有默认安装,所以我可以使用以下方法解决它:

brew install yasm
brew install ffmpeg

Had the same problem under Linux.在Linux下也有同样的问题。 By default the animate.save method is using ffmpeg but it seems to be deprecated.默认情况下 animate.save 方法使用 ffmpeg 但它似乎已被弃用。 https://askubuntu.com/questions/432542/is-ffmpeg-missing-from-the-official-repositories-in-14-04 https://askubuntu.com/questions/432542/is-ffmpeg-missing-from-the-official-repositories-in-14-04

Solution: Install some coder, like avconv or mencoder.解决方案:安装一些编码器,如 avconv 或 mencoder。 Provide the alternative coder in the call:在调用中提供替代编码器:

ani.save('the_movie.mp4', writer = 'mencoder', fps=15)

If you are using Ubuntu 14.04 ffmpeg is not available.如果您使用的是 Ubuntu 14.04,则ffmpeg不可用。 You can install it by using the instructions directly from https://www.ffmpeg.org/download.html .您可以直接使用https://www.ffmpeg.org/download.html 中的说明进行安装。

In short you will have to:简而言之,您将必须:

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg gstreamer0.10-ffmpeg

If this does not work maybe try using sudo apt-get dist-upgrade but this may broke things in your system.如果这不起作用,请尝试使用sudo apt-get dist-upgrade但这可能会破坏系统中的内容。

I had the following error while running the cell.运行单元时出现以下错误。 在此处输入图片说明

This may be due to not having ffmpeg in your system.这可能是由于您的系统中没有ffmpeg Try the following command in your terminal.在终端中尝试以下命令。

sudo apt install ffmpeg

This works for me.这对我有用。 I hope it will work out for you too.我希望它也适合你。

I'm running Ubuntu 20 and I had a similar problem我正在运行 Ubuntu 20,但我遇到了类似的问题

Installed ffmpeg安装了ffmpeg

pip install ffmpeg

then然后

sudo apt install ffmpeg

(be sure to follow JPH feedback above about the proper ffmpeg download) Not sure why, but in my case here is the one that worked (in my case was on windows). (请务必遵循上面关于正确 ffmpeg 下载的 JPH 反馈)不知道为什么,但在我的情况下,这是有效的(在我的情况下是在 Windows 上)。

Initialize a writer:初始化写入器:

import matplotlib.pyplot as plt
import matplotlib.animation as animation
Writer = animation.FFMpegWriter(fps=30, codec='libx264')  #or 
Writer = animation.FFMpegWriter(fps=20, metadata=dict(artist='Me'), bitrate=1800) ==> This is WORKED FINE ^_^

Writer = animation.writers['ffmpeg'] ==> GIVES ERROR ""RuntimeError: Requested MovieWriter (ffmpeg) not available"" Writer = animation.writers['ffmpeg'] ==> 给出错误“”运行时错误:请求的 MovieWriter(ffmpeg)不可用”“

If error "MovieWriter imagemagick unavailable; using Pillow instead."如果出现错误“MovieWriter imagemagick 不可用;请改用 Pillow。” pops up, try to import PillowWriter explicitly to save as mp4-File by:弹出,尝试显式导入 PillowWriter 以通过以下方式保存为 mp4-File:

from matplotlib.animation import FuncAnimation, PillowWriter

Use this command pip install ffmpeg使用此命令pip 安装 ffmpeg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM