You could use update-alternatives.
Use the --list option to see what it's installed:
# update-alternatives --list python
/opt/python3.1/bin/python3.1
/usr/bin/python
To update the alternatives table do (assuming /opt/python3.1/bin/python3.1 is the location where your python3.1 is istalled):
# update-alternatives --install /usr/bin/python python /opt/python3.1/bin/python3.1 2
The last 2 in the previous command specifies the priority. The highest number is set as the default in case there's no manual selection.
To switch between the listed Python alternatives:
# update-alternatives --config python
This command will prompt you to enter a selection number to choose the desired Python version.
If you want to change the Python version on a per-user basis, you can create an alias in your ~/.bashrc file. E.g:
$ alias python='/opt/python3.1/bin/python3.1'
After adding the alias, re-login or source your .bashrc file:
$ . ~/.bashrc
This will set the specified Python version as the default for your user
PATHvariable. Depending on what platform you are on, this is changed differently, but either way the point is to list the Python3 path before the Python2 path.