我從matplotlib例如一個非常簡單的代碼:「IO錯誤:[錯誤32]斷管」的蟒蛇蟒蛇保存動畫文件時
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
line, = ax.plot(np.random.rand(10))
ax.set_ylim(0, 1)
def update(data):
line.set_ydata(data)
return line,
def data_gen():
while True: yield np.random.rand(10)
ani = animation.FuncAnimation(fig, update, data_gen, interval=1000)
anim.save('basic_animation.mp4', fps=30)
plt.show()
一切都是正確的,如果我不使用anim.save( )功能。但是,當我想保存它時,它會報告:
IOError Traceback (most recent call last)
<ipython-input-6-8948bc3b3f5c> in <module>()
16
17 ani = animation.FuncAnimation(fig, update, data_gen, interval=1000)
---> 18 anim.save('basic_animation.mp4', fps=30)
19 plt.show()
....(traceback details are omitted here)
/home/xin/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_raw(self, filename_or_obj, *args, **kwargs)
517 close = False
518 try:
--> 519 fileobj.write(renderer._renderer.buffer_rgba())
520 finally:
521 if close:
IOError: [Errno 32] Broken pipe
我該如何解決它?或者還有其他方法可以將動畫保存到文件中嗎?
補充:要安裝的ffmpeg,我只需運行: 暢達安裝-c https://conda.anaconda.org/mutirri的ffmpeg
謝謝,但它仍然報告了同樣的問題.....我想這可能是壞了我的設置,因爲我是從拷貝確切的例子http://matplotlib.org/examples/animation/ basic_example.html,但仍然得到相同的報告... –