[英]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
我发现了类似的情况( link1 , link2 ),但我仍然不知道如何解决我的问题...
我正在使用: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.