How can I upgrade Python to 2.7.9 on Ubuntu 14.4?

Ubuntu 14.4 comes with Python 2.7.6 built-in, but I'd like to upgrade it to 2.7.9 (it has security features that I want).

Is that even possible? If so, how can this be achieved?


Solution 1:

You can use pyenv:

 git clone https://github.com/pyenv/pyenv.git ~/.pyenv
 git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

Then add

   #   for PyEnv
  export PYENV_ROOT="$HOME/.pyenv"
  export PATH="$HOME/.pyenv/bin:$PATH"
  export PATH="$HOME/.pyenv/shims:$PATH"
  eval "$(pyenv init -)"

to .bash_profile then you can see the python version you want to install or update:

pyenv install --list

want python 2.7.10? you can try:

 pyenv virtualenv 2.7.10

Hope it can help you.

Solution 2:

ppa:fkrull/deadsnakes is the latest version of python2.7

sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get upgrade

It will upgrade python to 2.7.10