Installation of Python 2.7.9 in Ubuntu 14.04

Ubuntu 14.04 ships with python 2.7.6 and uses it a lot for it’s internal needs. But python2.7.6 lacks very usefull module – ssl (https://docs.python.org/2.7/library/ssl.html). I like ssl.create_default_context a lot – saves a lot of work when dealing with HTTPS. So here are the steps to get separate installation of python2.7.9 leaving default 2.7.6 intact 1) You have clean Ubuntu 14.04 and now it’s time to install some important packages

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
sudo apt-get install checkinstall

2) Now let’s fetch python’s source and extract it to our home directory

mkdir ~/Downloads
cd ~/Downloads
wget http://python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar -xvf Python-2.7.9.tgz
cd Python-2.7.9

3) It’s time to compile to to a separate directory (say /opt/python-2.7.9)

sudo mkdir /opt/python279
./configure --prefix=/opt/python279
make

4) Here is an important step – we are not going to make install it, but use checkinstall instead. It will create deb package and install it (so it can be easily removed later if needed, for example). We will provide custom package (python-2.7.9) name to identify it later.

sudo checkinstall --pkgname python-2.7.9

5) That’s it. Type /opt/python279/bin/python -V and it will show the version 6) You can delete it later with sudo dpkg -r python-2.7.9

2 thoughts on “Installation of Python 2.7.9 in Ubuntu 14.04

  1. Step 4 results in the conversation below, and then it hangs on “Copying files to the temporary directory…” and does not come back.

    Should I say Yes to the exclude question?

    Some of the files created by the installation are inside the home directory: /home

    You probably don’t want them to be included in the package.
    Do you want me to list them? [n]:
    Should I exclude them from the package? (Saying yes is a good idea) [n]: n

    Some of the files created by the installation are inside the build
    directory: /home/sander/Downloads/Python-2.7.9

    You probably don’t want them to be included in the package,
    especially if they are inside your home directory.
    Do you want me to list them? [n]: n
    Should I exclude them from the package? (Saying yes is a good idea) [y]: n

    Copying files to the temporary directory…

    Like

  2. Update to my previous command: after waiting 5 more minutes, the “Copying files to the temporary directory.” succeeded, and it’s all working on my Ubuntu 14.04.

    Cool. Thank you!

    Some of the files created by the installation are inside the home directory: /home

    You probably don’t want them to be included in the package.
    Do you want me to list them? [n]:
    Should I exclude them from the package? (Saying yes is a good idea) [n]: n

    Some of the files created by the installation are inside the build
    directory: /home/sander/Downloads/Python-2.7.9

    You probably don’t want them to be included in the package,
    especially if they are inside your home directory.
    Do you want me to list them? [n]: n
    Should I exclude them from the package? (Saying yes is a good idea) [y]: n

    Copying files to the temporary directory…OK

    Stripping ELF binaries and libraries…OK

    Compressing man pages…OK

    Building file list…OK

    Building Debian package…OK

    Installing Debian package…OK

    Erasing temporary files…OK

    Writing backup package…OK
    OK

    Deleting temp dir…OK

    **********************************************************************

    Done. The new package has been installed and saved to

    /home/sander/Downloads/Python-2.7.9/python-2.7.9_2.7.9-1_amd64.deb

    You can remove it from your system anytime using:

    dpkg -r python-2.7.9

    **********************************************************************

    sander@flappie:~/Downloads/Python-2.7.9$ /opt/python279/bin/python -V
    Python 2.7.9

    Like

Leave a comment