运行时错误:Matplotlib动画中没有可用的电影编剧

2024-04-16 21:24:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我遇到的问题是代码与此示例类似: https://matplotlib.org/examples/animation/basic_example_writer.html

错误:

运行时错误:在上面的示例中,Writer = animation.writers['ffmpeg']处没有可用的电影编剧。

我使用的是mac,我已经用brew安装了ffmpeg,甚至还用conda安装了它,尽管我没有用anaconda来编写这个特定的代码。

我确信它已经安装了-我在终端中使用它来更改文件,但它在程序中不起作用。

谢谢!


Tags: 代码httpsorg示例basicmatplotlibexamplehtml
3条回答

我发现我的计算机中不存在“/usr/local/bin/ffmpeg”。所以我试试这个:

import matplotlib.pyplot as plt
import matplotlib.animation as animation
Writer = animation.writers['pillow']
writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)

对我也有用

尝试手动指定ffpmeg程序的路径,如下所示

import matplotlib.pyplot as plt
plt.rcParams['animation.ffmpeg_path'] = '/usr/local/bin/ffmpeg'

必须将这些代码行放在脚本的开头,然后使用动画Writer

不知道为什么,但在我的情况下,这是一个工作(在我的情况下是在windows上)。

初始化写入程序:

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']==>;给出错误“RuntimeError:请求的MovieWriter(ffmpeg)不可用”

相关问题 更多 >