How can I overcome this key word error?

混江龙づ霸主 提交于 2019-11-30 20:44:52
varzik

First install ffmpeg and add path to ffmpeg

# on windows
plt.rcParams['animation.ffmpeg_path'] = 'C:\\ffmpeg\\bin\\ffmpeg.exe'
# on linux
plt.rcParams['animation.ffmpeg_path'] = u'/home/username/anaconda/envs/env_name/bin/ffmpeg'    

Note for linux users: The path for ffmpeg can be found by simply using which: which ffmpeg

Also instead of

FFMpegWriter = animation.writers['ffmpeg']
writer = FFMpegWriter(fps=15, metadata=dict(artist='Me'),        bitrate=1800)

I just used writer = animation.FFMpegWriter()

It seems that ffmpegis not installed on your system. Try the following code:

import matplotlib.animation as animation
print(animation.writers.list())

It will print out a list of all available MovieWriters. If ffmpegis not among it, you need to install it first from the ffmpeg homepage.

If you have Homebrew, literally just run the command

brew install ffmpeg

And Homebrew will take care of the rest (dependencies, etc). If you don't, I would recommend getting Homebrew or something like it (apt-get on Linux is built in, or an alternative on OS X would be Macports)

user9949133

I have also posed with same problem(keyError: 'ffmpeg') but instead of using anakonda, I used IDLE3. So, first i checked for 'ffmpeg' in terminal it wasn't installed so installed it.

Using: sudo apt install ffmpeg

and when I run my save_animation program, it worked generating animation files in '.mpeg' format.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!