Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 it?

like image 627
Naveen Kumar Avatar asked Feb 08 '14 12:02

Naveen Kumar


People also ask

Does Python 3.10 support matplotlib?

Matplotlib is a NumFOCUS fiscally sponsored project. Matplotlib 2.0. x supports Python versions 2.7 through 3.10. Python 3 support started with Matplotlib 1.2.

How do I know if matplotlib is installed on Ubuntu?

To verify that Matplotlib is installed, try to invoke Matplotlib's version at the Python REPL. Use the commands below that include calling the . __version__ an attribute common to most Python packages.


2 Answers

One "cleaner" way to install matplotlib is to go through pip:

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

It will also ensure that you'll get the most up to date stable version and will be easier to maintain when an upgrade is pushed to pypi.

If the build process complains about missing headers files just install the missing lib with:

sudo apt-get install libfreetype6-dev libpng-dev

Warning: it can take a lot of time to fully build as one dependency of matplotlib is numpy which is quite a project in terms of c extension.

like image 199
Ketouem Avatar answered Oct 07 '22 22:10

Ketouem


type the following commands in 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 doesn't work properly, extract the files manually. $ cd matplotlib-matplotlib-bb3ea55 should be the proper directory (however the last seven characters may be different).

like image 43
Naveen Kumar Avatar answered Oct 08 '22 00:10

Naveen Kumar