本文介绍了如何保存 Animation.Artist 动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题:

我的程序运行良好,但是当我尝试保存我绘制的动画时,编译器响应错误.

My program is working well but when I try to save the animation that I plot, The compiler responds with an error.

代码:

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib.animation as animation

fig=plt.figure()
for infile in glob.glob('*.png'):
    img=mpimg.imread(infile)
    imgplot=plt.imshow(img)
    im_list2.append([imgplot])
ani = animation.ArtistAnimation(fig, im_list2, interval=50, blit=True)

但是当我尝试像这样保存它时:

But when I try to save it like this:

ani.save('Animation1.mp4')

它返回一个错误:

WindowsError: [错误 2] 系统找不到给定的数据.

推荐答案

我认为您遇到了几天前遇到的相同问题:是我发布的问题!

I think you are with the same problem I had few days ago: here is the question I posted!

我通过从 C:\Python27\Lib\site-packages\matplotlib\animation.py 更改第 163 行来解决我的问题

I solved my problem by changing line 163 from C:\Python27\Lib\site-packages\matplotlib\animation.py from

proc = Popen(command, shell=False, stdout=PIPE, stderr=PIPE)

proc = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)

...但是,我不确定animation.py文件中的此更改有多安全"!在此处查看更多信息.

...However, I am not sure how "safe" is this change in the animation.py file!See more info here.

这篇关于如何保存 Animation.Artist 动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 07:16