This post was written in 2012.
Since then many time has passed, and my recommendation is to use
pyenv + virtualenv
Original text is below:
So, ubuntu 12.04 comes with python 2.7 or 3.2 by default.
If installing 3.2 is easy as
sudo apt-get install python3
When you whant to install unsupported python version, you starting to have some troubles.
You can use projects like
pyenv, but also You can do it manually, wich were my choice.
1. Add repository from
https://launchpad.net/~fkrull/+archive/deadsnakes
sudo add-apt-repository ppa:fkrull/deadsnakes && sudo apt-get update
If Your system dont have command add-apt-repository install it by typing
sudo apt-get install python-software-properties
2. Now You can choose what version to install.
2.3 2.4 2.5 2.6 2.7 3.1 3.2 3.3 3.4
sudo apt-get install python3.1 libpython3.1 python3.1-minimal
Instead of
3.1 enter needed version.
3. To make system use Your installed python version, You have to make symlink to new installed python.
sudo unlink /usr/bin/python
sudo ln -s /usr/bin/python3.1 /usr/bin/python
Instead of 3.1 enter needed version.
Now just enter
python --version
And enjoy new python enviroment.
UPDATE:
You will most likely meet problem with this problem:
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 10, in <module>
import CommandNotFound
ImportError: No module named CommandNotFound
To solve it (sort of) do as follows:
sudo nano /etc/bash.bashrc
And comment with #
# if the command-not-found package is installed, use it
#if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
# function command_not_found_handle {
# # check because c-n-f could've been removed in the meantime
# if [ -x /usr/lib/command-not-found ]; then
# /usr/bin/python /usr/lib/command-not-found -- "$1"
# return $?
# elif [ -x /usr/share/command-not-found/command-not-found ]; then
# /usr/bin/python /usr/share/command-not-found/command-not-found -- "$1"
# return $?
# else
# printf "%s: command not found\n" "$1" >&2
# return 127
# fi
# }
#fi