【问题标题】:How Can I Save Animation.Artist animation?如何保存 Animation.Artist 动画?
【发布时间】:2012-03-04 15:17:16
【问题描述】:

我有一个问题:

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

代码:

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] 系统找不到给定的数据。

【问题讨论】:

  • 我提供了一个完整的最小示例来说明问题,它会更容易回答。
  • 如果您找到了问题的答案(如您对 india_dourada 答案的评论中给出的那样),您应该回答自己的问题并将其标记为已接受。

标签: python windows-xp matplotlib


【解决方案1】:

我想你和我几天前遇到的问题一样:here 是我发布的问题!

我通过将第 163 行从 C:\Python27\Lib\site-packages\matplotlib\animation.py 更改为

解决了我的问题
proc = Popen(command, shell=False, stdout=PIPE, stderr=PIPE)

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

...但是,我不确定 animation.py 文件中的这种更改有多“安全”! See more info here.

【讨论】:

  • 就我而言,我没有其他麻烦。我的动画已正确保存在应有的路径中。你知道你在哪个目录下工作吗?我建议你在脚本的开头选择你的目录(例如,如果你有一个名为 D:/CG/DREAM 的文件夹):os.chdir('D:/CG/DREAM') 然后,检查动画是否保存在这个文件夹中。
  • 不,我必须在 python 路径中添加一个名为 ffmpeg.exe (ffmpeg.zeranoe.com/builds) 的应用程序,然后它运行良好;)(也无需像您建议的那样从 False 更改为 True)跨度>
猜你喜欢
  • 2021-06-05
  • 1970-01-01
  • 2018-11-13
  • 1970-01-01
  • 2013-08-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多