记一次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'

至此,问题解决。

相关推荐
大神君Bob15 小时前
【AI办公自动化】如何使用Pytho让Excel表格处理自动化
python
Heorine15 小时前
数学建模 绘图 图表 可视化(6)
python·数学建模·数据可视化
栈与堆15 小时前
LeetCode-1-两数之和
java·数据结构·后端·python·算法·leetcode·rust
智航GIS15 小时前
10.7 pyspider 库入门
开发语言·前端·python
副露のmagic16 小时前
更弱智的算法学习 day25
python·学习·算法
hudawei99616 小时前
Flask 与 FastAPI 对比分析
python·flask·fastapi
寻星探路16 小时前
【Python 全栈测开之路】Python 基础语法精讲(一):常量、变量与运算符
java·开发语言·c++·python·http·ai·c#
智航GIS16 小时前
10.5 PyQuery:jQuery 风格的 Python HTML 解析库
python·html·jquery
小兔崽子去哪了17 小时前
机器学习,梯度下降,拟合,正则化,混淆矩阵
python·机器学习
缘友一世17 小时前
PyCharm连接autodl平台服务(python解释器&jupyter lab)
python·jupyter·pycharm