matplotlib.animation错误 - 系统找不到指定的文件 [英] matplotlib.animation error - The system cannot find the file specified

查看:1059
本文介绍了matplotlib.animation错误 - 系统找不到指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当试图运行在Python简单动画例如code ,我得到一个错误,我不能够解决的。

When trying to run a simple animation example code in python, I am getting an error which I am not able to resolve.

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

我发现了类似的情况下(<一个href=\"http://stackoverflow.com/questions/8928989/biopython-error-the-system-cannot-find-the-file-specified\">link1 , LINK2 ),但我仍然不知道如何解决我的...

I found similar situations (link1 , link2 ) but still I don't know how to resolve mine...

我使用:
Python的2.7.2 | EPD 7.2-2(32位)| (默认情况下,2011年9月14日,11:02:05)[MSC v.1500 32位(英特尔)]在Win32

I am using: Python 2.7.2 |EPD 7.2-2 (32-bit)| (default, Sep 14 2011, 11:02:05) [MSC v.1500 32 bit (Intel)] on win32

我希望有人能帮帮我!

推荐答案

我有同样的情况,但sollution很简单,如果你只是想看看动画。您的proglem就是ani.save('dynamic_images.mp4'),这是没有必要为动画本身有关。只是其注释掉。您code崩溃,由于缺乏安装$ C $立方厘米(最有可能)。 animation.py包含低于code。如果参数codec到_make_movie是无,ffmpeg的(google一下)时,那么你就需要有这样一个在你安装的路径和可用。否则,你可以使用男士codeR也需要安装和路径。

I had the same situation, but the sollution is simple if you just want to look at the animation. Your proglem is related to ani.save('dynamic_images.mp4'), which isn't needed for the animation itself. Just comment it out. Your code crashes due to lack of installed codec (most likely). animation.py contains the code below. If the argument codec to _make_movie is None, ffmpeg (google it) is used, then you need to have this one installed and available in your path. Otherwise you can use mencoder which also needs to be installed and in path.

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

这篇关于matplotlib.animation错误 - 系统找不到指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆