1

With pip installed, I am trying to install matplotlib in Ubuntu 12.04.4 LTS. I got the following error when executing "sudo pip install matplotlib" enter image description here

I guess this is because the python version is too old (2.7.3), So I follow this discussion, How to install the latest Python version on Debian separately or upgrade?, to build the latest 2.7.11 in /opt/python/.

My question is how to specify the newer version of python when installing matplotlib through pip?

Or should I just use "easy_install", which is not recommended by other people?

Thank you for precious time on my question.

1

Pip is bundled with Python 2.7.11 (they started adding it in 2.7.9 and 3.4), so you can use an included module to generate a short pip script:

$ /opt/python/bin/python -m ensurepip

That will make /opt/python/bin/pip, which has a shebang line pointing at /opt/python/bin/python, so you can run it when you want a pip that's associated with that particular Python installation.

If you're running an older Python, you can download get-pip.py and pass it to the Python you want to install it under:

$ wget 'https://bootstrap.pypa.io/get-pip.py'
$ /opt/python/bin/python ./get-pip.py

This will generate the same pip scripts. See the pip documentation for more information

0

Using the following worked for me:

sudo apt-get install python-matplotlib

The following page also has more information about installing matplotlib.

  • That works for this particular case, but the question is how to control which version of Python is used when running pip – Michael Mrozek Jan 14 '16 at 6:29
  • -1 because you just state another way without giving an answer why it works, what it does, what the difference is (yes, there is a huge difference between the two approaches) – Mayou36 Apr 12 '17 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.