跟随How to Create Animated Graphs in Python在构建动画情节时,然后在编写 ffmpeg 时出现以下错误:
'Requested MovieWriter ({}) not available'.format(name))
RuntimeError: Requested MovieWriter (ffmpeg) not available
收到此错误后,我最初尝试使用
pip
安装 ffmpeg通过以下方法:python -m install ffmpeg
它似乎已经成功安装了ffmpeg,但是回到我的代码我仍然得到同样的错误
在我的代码下面找到:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation
overdoses = pd.read_excel(r'C:\Users\ACER\Desktop\overdose_data_1999-2015.xls',sheet_name='Online',skiprows =6)
def get_data(table,rownum,title):
data = pd.DataFrame(table.loc[rownum][2:]).astype(float)
data.columns = {title}
return data
title = 'Heroin Overdoses'
d = get_data(overdoses,18,title)
x = np.array(d.index)
y = np.array(d['Heroin Overdoses'])
overdose = pd.DataFrame(y,x)
overdose.columns = {title}
Writer = animation.writers['ffmpeg']
这是堆栈跟踪:
Traceback (most recent call last):
File "C:\Python\Python36\lib\site-packages\matplotlib\animation.py", line 161, in __getitem__
return self.avail[name]
KeyError: 'ffmpeg'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
Writer = animation.writers['ffmpeg']
File "C:\Python\Python36\lib\site-packages\matplotlib\animation.py", line 164, in __getitem__
'Requested MovieWriter ({}) not available'.format(name))
RuntimeError: Requested MovieWriter (ffmpeg) not available
最佳答案
很明显,你还没有安装ffmpeg
(适本地)。它在安装过程中几乎看起来是一个权限问题?尝试卸载/清理ffmpeg
并进行适当的重新安装。
我看到您正在尝试关注 “How to Create Animated Graphs in Python.”为什么不直接跳过 ffmpeg
完全分开,只做一个plt.show()
最后看动画。
关于python - 如何绘制动画图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55890848/