How to install python-matplotlib in ubuntu 12.04?

When i tried

$ sudo apt-get install python-matplotlib 

I got the following error:

 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package python-matplotlib 

How to install this?

+6
source share
3 answers

enter the following commands into the terminal:

 $ wget https://github.com/matplotlib/matplotlib/zipball/master $ unzip master $ cd matplotlib-matplotlib-bb3ea55 $ sudo python2.7 setup.py build $ sudo python2.7 setup.py install 

If the unzip command does not work correctly, manually extract the files. $ cd matplotlib-matplotlib-bb3ea55 must be the appropriate directory (however, the last seven characters may be different).

+8
source

One β€œclean” way to install matplotlib is to go through pip:

 sudo apt-get install python-pip sudo pip install matplotlib 

It also ensures that you get the latest stable version and will be easier to maintain when the update is ported to pypi.

If the build process complains about missing header files, simply install the missing lib with:

 sudo apt-get install libfreetype6-dev libpng-dev 

Warning: it may take a long time to complete assembly, since one matplotlib dependency is numpy, which is quite a project in terms of c extension.

+40
source

Also, make sure you have the python-dev package.

If not, run:

 sudo apt-get install python-dev 
+6
source

All Articles