I am literally trying half a day to upgrade my python from 2.6 to 2.7 with no luck so far.
The linux distribution is:Red Hat Enterprise Linux Server release 6.5 (Santiago), and it came with python 2.6, which I want to now upgrade to python 2.7.
Here's the thing though; I already wrote huge amount of script lines in python 2.6, until I finally caved in to the need to use newer version of python. So I already have a lot of packages (filelock,argparse,paramkio,psutil,dill and more...), installed with pip install PACKAGE to my python 2.6 script.

When I finally figured out how to install python 2.7 (I'll add the commands for reference):

$ wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz --no-check-certificate
$ tar xf Python-2.7.6.tar.xz
$ cd Python-2.7.6
$ ./configure
$ make 
$ sudo make altinstall

I ran into some more problems...

First of all, python 2.7 was installed in /usr/local/bin/python2.7 while python 2.6 is at /usr/bin/python2.6. Naively, I thought that installing python 2.7 will upgrade(=overwrite) the existing python 2.6. So when typing python from shell, the interpreter used is still python 2.6, instead of the newly installed python 2.7.

Second, running pip install PACKAGE still tries to install the package for python 2.6:

$ pip install filelock
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
    Requirement already satisfied (use --upgrade to upgrade): filelock in /usr/lib/python2.6/site-packages

btw, I noticed that /usr/bin has both pip and easy_install in it, unlike /usr/local/bin/ (just in case this info can help solving this issue).

How do I solve these two issues?
I want python 2.7 to be picked whenever you type python from shell, preferably taking python 2.6's place in /usr/bin/, and I want pip to install packages for python 2.7.

I tried a lot of the suggested answers that seemed related, both here and in SO, but nothing seems to work for me.

1 Answer 1


In the README at the top of the source tree it describes many of the build choices you can make. In particular you can install the resulting files in /usr instead of the default /usr/local by doing

./configure --prefix=/usr
make clean
sudo make install

This will install, for example, /usr/bin/python as a symbolic link to python2, and that python2 as a symbolic link to python2.7, the real binary. You can easily check this before doing the final sudo make install by doing a non-root install into a simple subdir x:

make DESTDIR=x install

All the files will be installed under x and you can then browse to see that it corresponds to your needs. For example,

ls -l x/usr/bin/   
-rwxr-xr-x 1 meuh meuh      95 Sep 10 11:39 2to3
-rwxr-xr-x 1 meuh meuh      93 Sep 10 11:39 idle
-rwxr-xr-x 1 meuh meuh      78 Sep 10 11:39 pydoc
lrwxrwxrwx 1 meuh meuh       7 Sep 10 11:39 python -> python2
lrwxrwxrwx 1 meuh meuh      14 Sep 10 11:39 python-config -> python2-config
lrwxrwxrwx 1 meuh meuh       9 Sep 10 11:39 python2 -> python2.7
lrwxrwxrwx 1 meuh meuh      16 Sep 10 11:39 python2-config -> python2.7-config
-rwxr-xr-x 1 meuh meuh 7991432 Sep 10 11:39 python2.7
-rwxr-xr-x 1 meuh meuh    1668 Sep 10 11:39 python2.7-config
-rwxr-xr-x 1 meuh meuh   18541 Sep 10 11:39 smtpd.py
  • Great! Thanks. What about pip? How can I install packages for python 2.7? Sep 10, 2016 at 18:15
  • 1
    pip will just run the default python command, so if you have set /usr/bin/python2 to python2.7 it should work as you want. You can explicitly run python2.6 -m pip install SomePackage for example to force a particular version.
    – meuh
    Sep 10, 2016 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .