Website of Daniel A. Mayer

Installing Matplotlib and NumPy in a Virtualenv

Installing NumPy and matplotlib into a virtualenv using Python 2.7 should be an easy task, right? Turns out there are some hoops to jump through in order to make it work properly. Here is what worked for me on my Ubuntu 11.04 (Natty) system.

Installing NumPy

First, remove the system-wide NumPy and matplotlib packages (this might not be necessary though):

1
sudo apt-get remove python-numpy python-matplotlib

Install the atlas dev files

1
sudo apt-get install libatlas-base-dev

Apply the quickfix according to: https://github.com/pypa/virtualenv/issues/118

1
2
3
cd /path/to/virtualenv
mkdir local
ln -s ../lib local/lib

Actually install numpy in the virtualenv

1
pip -E /path/to/virtualenv install numpy

Installing Matplotlib

There is some problem with the version of matplotlib which is available in PyPi through pip or easy_install. However, when pointing pip directly to the matplotlib tarball, the installation succeeds without a problem.

1
pip install -E /path/to/virtualenv http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0.1/matplotlib-1.0.1.tar.gz

I'm sure this last command will require some Ubuntu/Debian developer packages to be installed. My system had everything which was required for the compilation to succeed. Feel free to leave me a comment and I will add a list of prerequisites here.

References

Comments