Linux Matplotlib-动画“没有可用的电影作家”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13316397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 17:44:56  来源:igfitidea点击:

Matplotlib-Animation "No MovieWriters Available"

pythonlinuxanimationmatplotlibruntime-error

提问by OverlordAlex

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 的动画类,它似乎有效,只是我无法初始化电影作家来写出电影。

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 中创建动画?

采纳答案by JPH

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 the exes from here.

从这里下载 exe。

http://ffmpeg.zeranoe.com/builds/

http://ffmpeg.zeranoe.com/builds/

Hope this helps someone - even after a while after the question - good luck

希望这对某人有所帮助 - 即使在问题过后一段时间 - 祝你好运

回答by Tapio

Had the same problem under Linux. By default the animate.save method is using ffmpeg but it seems to be deprecated. https://askubuntu.com/questions/432542/is-ffmpeg-missing-from-the-official-repositories-in-14-04

在Linux下也有同样的问题。默认情况下 animate.save 方法使用 ffmpeg 但它似乎已被弃用。 https://askubuntu.com/questions/432542/is-ffmpeg-missing-from-the-official-repositories-in-14-04

Solution: Install some coder, like avconv or mencoder. Provide the alternative coder in the call:

解决方案:安装一些编码器,如 avconv 或 mencoder。在调用中提供替代编码器:

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

回答by Ramon Martinez

If you are using Ubuntu 14.04 ffmpegis not available. You can install it by using the instructions directly from https://www.ffmpeg.org/download.html.

如果您使用的是 Ubuntu 14.04 ffmpeg,则不可用。您可以直接使用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-upgradebut this may broke things in your system.

如果这不起作用,请尝试使用,sudo apt-get dist-upgrade但这可能会破坏系统中的某些内容。

回答by patapouf_ai

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. I had the exact same problem on Mac because ffmpegis not installed by default apparently, and so I could solve it using:

我知道这个问题是关于 Linux 的,但是如果有人像我在这里那样在 Mac 上偶然发现这个问题,那么解决方案就是解决这个问题。我在 Mac 上遇到了完全相同的问题,因为ffmpeg显然默认情况下没有安装,所以我可以使用以下方法解决它:

brew install yasm
brew install ffmpeg

回答by fiat

For fellow googlers using Anaconda, install the ffmpegpackage:

对于使用 Anaconda 的谷歌员工,请安装ffmpeg包:

conda install -c conda-forge ffmpeg

This works on Windows too.

这也适用于 Windows。

(Original answer used menpopackage owner but as mentioned by @harsh their version is a little behind at time of writing)

(原始答案使用menpo包所有者,但正如@harsh 所提到的,在撰写本文时,他们的版本有点落后)

回答by HassanSh__3571619

(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) 不可用“”

回答by Nisan Chhetri

I had the following error while running the cell. enter image description here

运行单元时出现以下错误。 在此处输入图片说明

This may be due to not having ffmpegin your system. Try the following command in your terminal.

这可能是由于ffmpeg您的系统中没有。在终端中尝试以下命令。

sudo apt install ffmpeg

This works for me. I hope it will work out for you too.

这对我有用。我希望它也适合你。