Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing matplotlib for python3 on Ubuntu

I'm running Ubuntu 12.04, and I need to use matpltlib in Python 3.2.3. I successfully installed it using

sudo apt-get install python-matplotlib

But now it works only in Python 2.7, which seems to be the default version:

$ python2
Python 2.7.3 (default, Feb 27 2014, 20:00:17) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> 

But python 3 doesn't work:

$ python3
Python 3.2.3 (default, Feb 27 2014, 21:33:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>> 

Also, my python command seems to be 'broken':

$ python
bash: /usr/bin/python: No such file or directory

Any help is appreciated!

like image 938
Sean Bone Avatar asked Oct 24 '25 10:10

Sean Bone


1 Answers

In case anyone else stumbles upon this, just use

sudo apt-get install python3-matplotlib

There are many packages involved with matplotlib and using apt-get instead of pip this is the officially recommended approach.

like image 198
Dawid Laszuk Avatar answered Oct 26 '25 22:10

Dawid Laszuk