簡體   English   中英

matplotlib.animation錯誤-系統找不到指定的文件

[英]matplotlib.animation error - The system cannot find the file specified

嘗試在python中運行簡單的動畫示例代碼時,出現了我無法解決的錯誤。

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

我發現了類似的情況( link1link2 ),但我仍然不知道如何解決我的問題...

我正在使用:Python 2.7.2 | EPD 7.2-2(32位)| (默認值,2011年9月14日,11:02:05)[win32上的[MSC v.1500 32位(英特爾)]]

我希望有人能幫助我!

我也有同樣的情況,但是如果您只想看動畫,解決方法很簡單。 您的問題與ani.save('dynamic_images.mp4')有關,動畫本身不需要。 只是注釋掉。 您的代碼由於缺少已安裝的編解碼器而崩潰(很可能)。 animation.py包含以下代碼。 如果_make_movie的參數編解碼器為None(無),則使用ffmpeg(使用google),那么您需要在路徑中安裝並使用該參數。 否則,您可以使用mencoder,它也需要安裝並在路徑中。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM