Sean Bone
Sean Bone

Reputation: 3546

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!

Upvotes: 4

Views: 29585

Answers (2)

Wanz Hated
Wanz Hated

Reputation: 1

if you are in virtualenv example: workon cv #cv is my virtualenv name

$ workon cv
$ pip install matplotlib

Upvotes: 0

Dawid Laszuk
Dawid Laszuk

Reputation: 1978

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.

Upvotes: 11

Related Questions