Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python matplotlib.animation:脚本在Windows下工作,在Linux下工作用于短动画,但在长动画下无限期挂起?_Python_Animation_Matplotlib_Debian - Fatal编程技术网

Python matplotlib.animation:脚本在Windows下工作,在Linux下工作用于短动画,但在长动画下无限期挂起?

Python matplotlib.animation:脚本在Windows下工作,在Linux下工作用于短动画,但在长动画下无限期挂起?,python,animation,matplotlib,debian,Python,Animation,Matplotlib,Debian,以下是相关的代码片段: ani = animation.FuncAnimation(fig, animate, outputFiles, blit=True, interval=25) print "Starting to write animation file..." # Set up formatting for the movie files Writer = animation.writers['ffmpeg'] fps = 2 animationFileName = "anima

以下是相关的代码片段:

ani = animation.FuncAnimation(fig, animate, outputFiles, blit=True, interval=25)

print "Starting to write animation file..."
# Set up formatting for the movie files
Writer = animation.writers['ffmpeg']

fps = 2
animationFileName = "animation"
if fps <= 2:
    animationFileName = animationFileName + "_slow.mp4"
if fps < 120:
    animationFileName = animationFileName + ".mp4"
else:
    animationFileName = animationFileName + "_fast.mp4"

writer = Writer(fps=fps, metadata=dict(artist='Alien'), bitrate=1800)
ani.save(os.path.join(graphicsOutputDirectory, animationFileName), writer=writer)
print "Finished writing animation file..."
在Windows中,脚本运行正常。我确保我没有犯愚蠢的错误,比如使用错误的文件名。短动画似乎在我的GNU/Linux机器上运行得很好,而长一些的更严肃的动画似乎无限期地挂起


这里的问题可能是什么?我想我应该提到的一个相关细节是,我正在使用virtualenvironment来运行matplotlib的最新版本

Ubuntu和Debian现在附带了不推荐的FFMPEG版本。这可能就是问题所在。尝试将/usr/bin中的ffmpeg二进制文件替换为ffmpeg网站上最近的一个


另一个可能的问题与Python3有关,在Python3中,子进程的缓冲区较小,如果ffmpeg将太多信息发送回Python,子进程将永远挂起。您使用的是Python 3吗?

您能提供足够的代码来重现问题吗?我在linux+py2k上从来没有遇到过问题。@t我不确定我是否能够以可读的方式做到这一点……我想知道这个问题是否与“ffmpeg”matplotlib动画编写器在GNU/linux上(通常)不安全有关?也许我应该用另一个?我在这里发布了一个这样的问题,但似乎完全被误解了:据我所知,ffmpeg编写器在linux中很好,我真的不知道“不安全”是什么意思。Python3K和管道(在ffmpeg编写器中使用)存在一些已知问题。如果没有一个表现糟糕的示例,任何人都无法帮助您。@Zulko我不在Python 3上。我认为这可能是个问题,你是对的。另外,我还发现其他人也有这个问题:@tcaswell请看上面的评论——我认为这与ffmpeg编写器忽略“安静”设置有关。也许是因为不推荐的FFMPEG版本?
>>> python make_animation.py
Starting to run animation file...