2

I have a problem:

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

The Code:

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')

It returns an error:

WindowsError: [Error 2] The system could not find the given data.

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
Mik Il Pedro
  • 31
  • 1
  • 2
  • I you provide a complete minimal example demonstrating the problem, it'd be much easier to answer. – ev-br Feb 13 '12 at 15:22
  • If you have found the answer to your question (as given in your comment to the answer by india_dourada) you should answer your own question and mark it as accepted. – bmu May 17 '12 at 08:12

1 Answers1

3

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

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)

to

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

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

Community
  • 1
  • 1
carla
  • 2,181
  • 19
  • 26
  • In my case, I had no aditional trouble. My animation was properly saved in the path it was supposed to. Do you know in which directory are you working on? I suggest that you choose your directory in the beginning of your script (for example, if you have a folder named D:/CG/DREAM): `os.chdir('D:/CG/DREAM')` Then, check if the animation is saved on this folder. – carla Feb 15 '12 at 18:09
  • No I had to add to the python path an application called ffmpeg.exe (http://ffmpeg.zeranoe.com/builds/), and then it works well ;) (Also without changing from False to True like you suggested) – Mik Il Pedro Feb 20 '12 at 13:57