[英]matplotlib.animation error - The system cannot find the file specified
When trying to run a simple animation example code in python, I am getting an error which I am not able to resolve. 尝试在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
I found similar situations ( link1 , link2 ) but still I don't know how to resolve mine... 我发现了类似的情况( link1 , link2 ),但我仍然不知道如何解决我的问题...
I am using: Python 2.7.2 |EPD 7.2-2 (32-bit)| 我正在使用:Python 2.7.2 | EPD 7.2-2(32位)| (default, Sep 14 2011, 11:02:05) [MSC v.1500 32 bit (Intel)] on win32
(默认值,2011年9月14日,11:02:05)[win32上的[MSC v.1500 32位(英特尔)]]
I hope somebody can help me! 我希望有人能帮助我!
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.
您的问题与ani.save('dynamic_images.mp4')有关,动画本身不需要。 Just comment it out.
只是注释掉。 Your code crashes due to lack of installed codec (most likely).
您的代码由于缺少已安装的编解码器而崩溃(很可能)。 animation.py contains the code below.
animation.py包含以下代码。 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.
如果_make_movie的参数编解码器为None(无),则使用ffmpeg(使用google),那么您需要在路径中安装并使用该参数。 Otherwise you can use mencoder which also needs to be installed and in path.
否则,您可以使用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.