0

I have a virtual machine set up running Ubuntu 14.04.4 which has Python 2.7.6 by default. I've since installed Python 2.7.11 using the instructions here, which has left me with a python installation in /usr/local/bin/ that contains a python2.7 executable.

I've looked around for answers on this but most solutions seem to rely on the minor version being different for the two installs, 2.6 vs 2.7 for example. In this particular case both installs are 2.7.x which is making it difficult to differentiate between the two. This could hint at the need to simply update the default installation rather than installing a separate version entirely, however the articles I've read on the subject suggest otherwise.

If I run the following commands:

which python python -V

I get:

/usr/bin/python 2.7.6

And if I run:

which python2.7 python2.7 -V

I get:

/usr/local/bin//python2.7 2.7.11

All fine so far. However, if I now decide to install pip and then install python modules, pip and those modules will only be installed for the pre-existing version of python, not the version I installed locally.

With all that in mind, my question is how do I go about installing pip and any modules I need for my local version of python, and how do I tell Ubuntu I want to use my own python for development?

Also, I've seen some articles making heavy use of virtualenv for this, but as I'm aiming to have one virtual machine per project I'm hoping to avoid virtualenv for now, partly to simplify the process of working in the VM and partly for my own learning.

Thanks.

  • 2
    Possible duplicate of What's the best way to get Python 2.5 and 2.7 – dobey Feb 26 '16 at 16:26
  • It's better to use packages if you really need to. FWIW, though, the 2.7 packages in Ubuntu contain all the security fixes from up to 2.7.11 already. Or you may wish to backport the 2.7.11 package from 16.04 to 14.04 (or, in 2 months, simply update to 16.04). Also, unless you absolutely require 2.x, you should probably be using python3 anyway. :) – dobey Feb 26 '16 at 16:29
  • Thanks dobey. I do need to stick to 2.7 unfortunately as I'm setting this up for a project using that version of Python. Could you elaborate on what you mean by using packages or provide a link? I'm new to Linux so I'm not clear on what you mean. – Cral Feb 26 '16 at 16:32
  • The question I've suggested this is a duplicate of, has a link to the deadsnakes PPA, which has generally been the recommended way to install newer python packages. – dobey Feb 26 '16 at 18:13
0

I've decided to stick with the packages contained in Ubuntu. As dobey mentions they already contain the necessary security fixes, so trying to replace them with a slightly newer patch version doesn't seem like a good choice, especially when that version will be including in a coming update soon anyway.

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.