Search code examples
pythonpython-2.7debianaptitude

How can I upgrade python on a Debian server?


I just created a Debian 8 cloud server and it has Python 2.7.9 installed by default, even after sudo aptitude update && sudo aptitude upgrade. How can I upgrade python (in /usr/bin/python) to 2.7.11?

I've tried:

sudo aptitude install python
sudo aptitude install python2.7

to no avail.


Solution

  • You could also compile the latest source and install Python to an alternative path from the default (so that applications don't get messed up). Basically you would download the latest Python, configure it, compile, then install.

    $> wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
    $> tar xvhf Python-2.7.11.tgz
    $> cd Python-2.7.11
    $> ./configure
    $> make
    $> sudo make altinstall
    

    Update

    To see all the available options for Python configuration execute ./config --help. This is important to know because, by default, many options are left out (especially in Python 2.x) such as unicode or IPv6 support. Features can also be disabled if required.

    Reference