Matplotlib MovieWriters animation not working on Ubuntu 12.04

I am trying to keep a matplotlib animation in a movie across ffmpeg

on Ubuntu 12.04 LTS (32-bit desktop). Following the matplotlib example , it doesn't 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']

      

Through apt-get

I tried to install ffmpeg, every codec imaginable, and even tried to compile ffmpeg from source. Nothing works.

How do I get matplotlib

to talk to ffmpeg on Ubuntu?

+3


source to share


1 answer


If you are using the unbuntu

packaged version matplotlib

, this is 1.1.1rc1

. The attribute writers

was added about 3 months after this tag and is in versions 1.2

and later.

You can install matplotlib

from source (that's what I'm doing, it's not too bad) or you can use the daily ppa .

My advice for compiling from source is to use the packaging system for as many dependencies as possible and install matplotlib

manually (if you 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/

      



(which will give you the latest stable release), then make sure the path where it was installed is in yours $PYTHONPATH

, which can be done by including the line

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

      

in your file ~/.bashrc

. You may need to change this line slightly depending on the version of python you are using. You may need to do this (and make sure the folders exist) before you setup.py

are happy.

+4


source







All Articles