2012-02-09 23 views
5

Al intentar ejecutar un simple animation example code en python, recibo un error que no puedo resolver.matplotlib.animation error - El sistema no puede encontrar el archivo especificado

Traceback (most recent call last): 
File "D:/CG/dynamic_image2.py", line 29, in <module> 
    ani.save('dynamic_images.mp4') 
File "C:\Python27\lib\site-packages\matplotlib\animation.py", line 127, in save 
    self._make_movie(filename, fps, codec, frame_prefix) 
File "C:\Python27\lib\site-packages\matplotlib\animation.py", line 164, in _make_movie 
    stdout=PIPE, stderr=PIPE) 
File "C:\Python27\lib\subprocess.py", line 679, in __init__ 
    errread, errwrite) 
File "C:\Python27\lib\subprocess.py", line 893, in _execute_child 
    startupinfo) 
WindowsError: [Error 2] The system cannot find the file specified 

me encontré con situaciones similares (link1, link2), pero aún no sé cómo resolver la mía ...

estoy usando: Python 2.7.2 | EPD 7.2-2 (32 -bit) | (predeterminado, 14 de septiembre de 2011, 11:02:05) [MSC v.1500 32 bit (Intel)] en win32

¡Espero que alguien me pueda ayudar!

+0

me di cuenta que se puede ejecutar el código y obtener la animación, si cambio de la línea 163 desde ** C: \ python27 \ Lib \ site-packages \ matplotlib \ animation.py ** 'de proc = Popen (comando, shell = False, stdout = PIPE, stderr = PIPE) 'a' proc = Popen (comando, shell = True, stdout = PIPE, stderr = PIPE) '. – carla

+0

Sin embargo, no estoy seguro de qué tan "seguro" es este cambio en el archivo ** animation.py ** ... [más información aquí] (http://docs.python.org/library/subprocess.html#frequently -used-arguments) – carla

Respuesta

1

Tuve la misma situación, pero la solución es simple si solo quieres ver la animación. Tu proglem está relacionado con ani.save ('dynamic_images.mp4'), que no es necesario para la animación en sí. Solo comentenlo. El código se bloquea debido a la falta de códec instalado (lo más probable). animation.py contiene el código a continuación. Si el argumento codec a _make_movie es None, se usa ffmpeg (google it), entonces necesita tener este instalado y disponible en su ruta. De lo contrario, puede utilizar el mencoder que también debe instalarse y en la ruta.

def ffmpeg_cmd(self, fname, fps, codec, frame_prefix): 
    # Returns the command line parameters for subprocess to use 
    # ffmpeg to create a movie 
    return ['ffmpeg', '-y', '-r', str(fps), '-b', '1800k', '-i', 
     '%s%%04d.png' % frame_prefix, fname] 

def mencoder_cmd(self, fname, fps, codec, frame_prefix): 
    # Returns the command line parameters for subprocess to use 
    # mencoder to create a movie 
    return ['mencoder', 'mf://%s*.png' % frame_prefix, '-mf', 
     'type=png:fps=%d' % fps, '-ovc', 'lavc', '-lavcopts', 
     'vcodec=%s' % codec, '-oac', 'copy', '-o', fname] 

def _make_movie(self, fname, fps, codec, frame_prefix, cmd_gen=None): 
    # Uses subprocess to call the program for assembling frames into a 
    # movie file. *cmd_gen* is a callable that generates the sequence 
    # of command line arguments from a few configuration options. 
    from subprocess import Popen, PIPE 
    if cmd_gen is None: 
     cmd_gen = self.ffmpeg_cmd 
    command = cmd_gen(fname, fps, codec, frame_prefix) 
    verbose.report('Animation._make_movie running command: %s'%' '.join(command)) 
    proc = Popen(command, shell=False, 
     stdout=PIPE, stderr=PIPE) 
    proc.wait() 
+0

Tienes razón. De hecho, tuve ffmpeg instalado pero no estaba en mi ruta de Python ... Esta [pregunta stackoverflow] (http://stackoverflow.com/questions/9256829/how-can-i-save-animation-artist-animation/9281433 # 9281433) ¡ya me dieron esa pista! ¡Gracias por su ayuda! – carla

Cuestiones relacionadas