For whatever reason you may want to upgrade your version of Python that came with your Ubuntu distro. However, completely replacing the system version is not recommended. Here is how to install Python for the local user.
Python 2.7.10
$ mkdir ~/local/python-2.7.10
$ cd ~/Downloads
$ wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
$ tar -zxvf Python-2.7.10.tgz
$ cd Python-2.7.10
$ ./configure --prefix=/home/<user>/local/python-2.7.10
$ make
$ make install
$ ~/local/python-2.7.10/bin/python --versionPython 3.5.1
$ mkdir ~/local/python-3.5.1
$ cd ~/Downloads
$ wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
$ tar -zxvf Python-3.5.1.tgz
$ cd Python-3.5.1
$ ./configure --prefix=$HOME/local/python-3.5.1/
$ make
$ make test
$ make install
$ ~/local/python-3.5.1/bin/python3 --versionTips
- While in the Python source directory you should also check out the README for any extra help on the installation process.
cat README | less - View the configuration help with
./configure --helpwhile in the Python source directory.
Quick Start with Python 3.5.1
$ mkdir ~/sandbox/python3-playground
$ cd ~/sandbox/python3-playground
$ ~/local/python-3.5.1/bin/pyvenv env
$ . env/bin/activate
(env) $ pip install django
(env) $ ...
(env) $ deactivate
$ exitLearn more about virtual environments in Python 3.5.1 here.
References
- http://askubuntu.com/questions/572973/how-to-update-python-version-on-ubuntu-14-10
- http://stackoverflow.com/q/1534210/391924
$ cd ~/Downloads
$ wget https://bootstrap.pypa.io/get-pip.py
$ ~/local/python-2.7.10/bin/python get-pip.py
$ ~/local/python-2.7.10/bin/pip --versionReferences
$ ~/local/python-2.7.10/bin/pip install virtualenvReferences
$ mkdir ~/projects/helloworld
$ cd ~/projects/helloworld
$ ~/local/python-2.7.10/bin/virtualenv env
$ . env/bin/activate