Matplotlib动画MovieWriters在Ubuntu 12.04上失败 [英] Matplotlib animation MovieWriters fails on Ubuntu 12.04

查看:176
本文介绍了Matplotlib动画MovieWriters在Ubuntu 12.04上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Ubuntu 12.04 LTS(32位桌面)上的 ffmpeg 将电影文件保存到电影中。在matplotlib 示例之后,无法加载动画作者: AttributeError:'module'对象没有属性'writers'(示例第15行):

I am attempting to save matplotlib animations to a movie via ffmpeg on Ubuntu 12.04 LTS (32-bit Desktop). Following the matplotlib example, it fails to load the animation writer: AttributeError: 'module' object has no attribute 'writers' (line 15 of the example):

import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.animation as animation

def update_line(num, data, line):
    line.set_data(data[...,:num])
    return line,

# Set up formatting for the movie files
Writer = animation.writers['ffmpeg']

Via apt-get ,我已经尝试安装ffmpeg,每个编解码器都可以想象,甚至尝试从源代码编译ffmpeg。没有什么工作。

Via apt-get, I've tried installing ffmpeg, every codec imaginable, and even tried to compile ffmpeg from source. Nothing works.

如何获取 matplotlib 在Ubuntu上与ffmpeg通话?

How do I get matplotlib to talk to ffmpeg on Ubuntu?

推荐答案

如果您使用 unbuntu 打包版本的 matplotlib 它是 1.1.1rc1 。在该标签大约3个月之后添加了作者的属性,并且位于版本 1.2 及更高版本中。

If you are using the unbuntu packaged version of matplotlib it is 1.1.1rc1. The attribute writers was added about 3 months after that tag, and is in versions 1.2 and later.

您可以从源代码安装 matplotlib (这是我做的,这不算太糟糕)或使用每日ppa

You can either install matplotlib from source (this is what I do, it's not too bad) or use the daily ppa.

我从源代码编译的建议是尽可能多地使用包装系统,并手动安装 matplotlib (如果你想使用pip 看到这个答案)这样

My advice for compiling from source is to use the packaging system for as many of the dependencies as possible and install matplotlib by hand (if you do want to use pip see this answer) as such

git clone git://github.com/matplotlib/matplotlib.git
cd matplotlib
git checkout -b v1.2.0
python setup.py install --prefix=/home/username/local_installs/

(这会让你最新的稳定版本),然后确保安装路径在您的 $ PYTHONPATH 中,可以通过添加行

(which will get you the latest stable version) then make sure the path where it got installed is in your $PYTHONPATH which can be done by including the line

export PYTHONPATH=/home/username/local_installs/lib/python2.7/site-packages/:$PYTHONPATH

在你的〜/ .bashrc 文件。您可能需要根据您使用的python版本来改变该行。在 setup.py 之前,您可能需要执行此操作(并确保文件夹存在)。

in your ~/.bashrc file. You might have to vary that line a bit depending on which version of python you use. You might need to do this (and make sure folders exist) before setup.py will be happy.

这篇关于Matplotlib动画MovieWriters在Ubuntu 12.04上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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