我该如何保存Animation.Artist动画?
我遇到了一个问题:
我的程序运行得很好,但当我尝试保存我绘制的动画时,编译器却给我报错。
代码如下:
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)
但是当我试着这样保存的时候:
ani.save('Animation1.mp4')
它返回了一个错误:
WindowsError: [错误 2] 系统找不到指定的数据。
1 个回答
3
我觉得你遇到的问题和我几天前遇到的很像:这是我发的提问链接!
我通过修改C:\Python27\Lib\site-packages\matplotlib\animation.py文件的第163行解决了我的问题,具体改动是把
proc = Popen(command, shell=False, stdout=PIPE, stderr=PIPE)
改成
proc = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
...不过,我不太确定这样修改animation.py文件是否安全!想了解更多信息可以看这里。