2

I am new in Python and would like to save animations. Here is a minimal working environment:

import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
from numpy import pi

X,Y = np.meshgrid(np.arange(0,2*np.pi,.2),np.arange(0,2*np.pi,.2) )  
U = np.cos(X)
V = np.sin(Y)

fig,ax = plt.subplots(1,1)
Q = ax.quiver( X, Y, U, V, pivot='mid', color='r', units='inches')

ax.set_xlim(0, 2*pi)
ax.set_ylim(0, 2*pi)

def update_quiver(num, Q, X, Y):
    U = np.cos(X + num*0.1)
    V = np.sin(Y + num*0.1)
    Q.set_UVC(U,V)
    return Q,


anim = animation.FuncAnimation(fig, update_quiver, fargs=(Q, X, Y),
    interval=10, blit=False)


mywriter = animation.FFMpegWriter()
anim.save('mymovie.mp4',writer=mywriter)

I get the error message:

mywriter = animation.FFMpegWriter()
AttributeError: 'module' object has no attribute 'FFMpegWriter'

Any help will be highly appreciated!

  • Have a look at [this](http://stackoverflow.com/a/20395798/1272394). – Drewness Mar 23 '14 at 17:02
  • @Drewness Thank you! but what one may include? they didn't show anythings!! Thanks –  Mar 23 '14 at 17:06
  • @Drewness Their answer was quite ambiguous! Could you please expaline more? –  Mar 23 '14 at 17:08
  • @Drewness What I included in my code was the short answer described in the link you mentioned but it doesn't work!! Do you know why? Thanks a lot –  Mar 23 '14 at 17:10
  • Do you have FFMpeg installed? What version of matplotlib are you using? The code you posted does work for me using matplotlib 1.3.1. – unutbu Mar 23 '14 at 17:23
  • @unutbu Yes, I have installed successfully FFmpeg. How can I know the matplot version?! sorry I am new here, thanks a lot! –  Mar 23 '14 at 17:26
  • @unutbu I suppose that the version is 1.3.1 since I downloaded it recently. Do you have any idea about the error message I get when I call save? Thank you –  Mar 23 '14 at 17:32
  • @unutbu The strange thing I get when I remove the two last lines and write instead `anim.save('mymovie.mp4')` is that I obtain several images named _tmpXXXX.png (XXXX design numbers from 1 to 100). And surprisingly these images disappear simultaneously without giving birth to the desired video!!! Do you have any interpretation of that? Thanks a lot! –  Mar 23 '14 at 17:38
  • I'm not sure what the problem is, but perhaps in the python interpreter type: `import matplotlib.animation as animation`, and then `animation.writers.avail`. Edit your question to show the result. – unutbu Mar 23 '14 at 20:23
  • @unutbu The problem has been solved! It was the version of matplotlib the origin of the problem. Installing the new version solved the problem definitely! Thank you –  Mar 24 '14 at 21:39
  • Oh, good. I'm glad you found the solution! – unutbu Mar 24 '14 at 21:42

0 Answers0