Updating Matplotlib on Ubuntu 12.04

For me, installing matplotlib has a long history of being difficult. To make things worse, the documentation has several conflicting versions. I suspect many users install matplotlib as part of a bigger data analysis package. I have had good luck with that in the past. But my current project does not need all that machinery.

The reason I want to update matplotlib is I want to use mpld3. It says it needs v1.3.. I have v1.1.1r.

The instructions say to use the “Software Center”, but it only installs 1.1.1. (for Ubuntu 12.04)

One instruction says to use easy_install:

sudo easy_install -m matplotlib

This lead to a bunch of error messages. The one about “installed –multi-version” seemed troublesome. So I used the software center to remove python-matplotlib. While I was at it, I switched to pip.

sudo pip install matplotlib==1.4.3

This installed, but when I ran python and tried to import matplotlib, I got:

ImportError: No module named six


sudo pip install six

Gave requirement already satisfied. So I ran:

sudo pip install six --upgrade

Now it works!

In the past, because install was such a headache, I would just use symlinks to get matplotlib into my virtualenv. Maybe I can install directly in my virtualenv?

pip install numpy
pip install matplotlib==1.4.3

That worked too!!!


My success above gave me the courage to install matplotlib on a new Ubuntu 14.04 system. Here is the error I got:

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-t_uOOZ/matplotlib

Scrolling up the screen shows I a missing several dependencies. Here is how I installed them:

sudo apt-get install libfreetype6-dev libxft-dev
sudo apt-get install libpng-dev

Now pip install matplotlib works.


One thought on “Updating Matplotlib on Ubuntu 12.04

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s