4

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!

5
  • 1
    Do you have pip for python3 installed (possibly called pip3)? Then install all your python3 module through pip3 instead: pip3 install matplotlib. Commented Jun 27, 2014 at 10:12
  • The broken python command may be(come) an issue for your OS: some system tools probably use /usr/bin/python. It's a different problem, so better ask a new question just for that (possibly on askubuntu.com instead). Commented Jun 27, 2014 at 10:14
  • @Evert Thanks for the answer! Unfortunately the broken command is also preventing me from tryig this, so I'll have to fix that first. ~$ pip3 install matplotlib \n bash: /usr/bin/python: No such file or directory Commented Jun 27, 2014 at 11:58
  • that's easily circumvented by running ~$ python3 <full/path/to/pip3> install matplotlib. Commented Jun 27, 2014 at 12:03
  • iirc you need to install python3-matplotlib Commented Jun 27, 2014 at 15:38

2 Answers 2

11

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.

Sign up to request clarification or add additional context in comments.

1 Comment

In case anyone else is stuck with an old version of Ubuntu (12.04 in this question). This (no longer) works. There is no python3-matplotlib. Neither is pip3 available. See askubuntu.com/questions/412178/…
0

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

$ workon cv
$ pip install matplotlib

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.