记一次Python matplotlib使用ffmpeg和imagemagick错误

问题出现

朋友找我画一个摆线图,手工画起来抓急,于是求助于程序,想把绘制动画表达出来发给朋友,用ffmpeg和imagemagick分别存储视频和动图格式,结果出现如下两种错误:

MovieWriter ffmpeg unavailable; using Pillow instead

MovieWriter imagemagick unavailable; using Pillow instead.

分别提示找不到ffmpge和imagemagick程序。

问题解决

按照缺啥补啥的原则,分别下载ffmpeg和imagemagick两个程序,并解压到特定的目录,我分别从如下两个地方下载:

ffmpeg二进制文件

https://github.com/GyanD/codexffmpeg/releases

imagemagick二进制文件

https://imagemagick.org/script/download.php

这时候,我们可以把本地存储路径加入到环境变量path中,也可以在我们的程序里显式配置(我选择了后者,我的系统环境是Windows),代码如下:

python 复制代码
# 配置ffmpeg路径
plt.rcParams['animation.ffmpeg_path'] = r'J:\software\ffmpeg-7.0.1-full_build\bin\ffmpeg.exe'
# 通过convert_path设置ImageMagick路径
plt.rcParams['animation.convert_path'] = r'J:\software\ImageMagick-7.1.1-33-portable-Q16-x64\convert.exe'

至此,问题解决。

相关推荐
外收内放6 小时前
面向对象高级(实战案例)
开发语言·python·学习
专业程序开发源6 小时前
springboot欧缇蔓月子中心管理系统82697-计算机课程设计、毕业设计
java·spring boot·后端·python·spring·django·课程设计
FPGA小迷弟7 小时前
用 Claude Code 重构遗留系统:从评估到落地的完整实践指南
c++·python·ai·plotly·django·ai编程·claude
卷无止境7 小时前
面向arm64桌面客户端开发全景:语言、框架与生态
后端·python
fanruitian7 小时前
python else用法
开发语言·python
Thinker QAQ7 小时前
并发编程(十一):Shared Memory 与 Message Passing——关系与组合使用
java·python·go·并发编程·shared memory·message passing
用户8356290780518 小时前
如何使用 Python 对 Excel 数据进行分组和分级显示
后端·python
vx_Biye_Design8 小时前
django房屋租赁推荐系统78455-计算机课程设计、毕业设计
vue.js·spring boot·后端·python·django·课程设计·express
学Linux的语莫9 小时前
python中类的常见写法
开发语言·python·状态模式
垆边人似月.10 小时前
Python中如何使用get函数实现频次查询
服务器·前端·python