Quick notes on installing an updated version of Python on Ubuntu…

Use this:


$ sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install python3.5

To install pip in python3.5:


Thank you @NomadNella

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

Install the following packages:

sudo apt-get install python3.5
sudo apt-get install python3.5-dev

At this point you can install pip by doing:

wget https://bootstrap.pypa.io/get-pip.py
sudo python3.5 get-pip.py

Then you need to run (to put packages in the correct python3.5 directories):

sudo pip3 install -U <package-name>

OR continue to make Python3.5 perminent:
Change python3 link to point to python3.5 instead of python3.4 (/usr/bin/)

sudo mv /usr/bin/python3 /usr/bin/python3-old
sudo ln -s /usr/bin/python3.5 /usr/bin/python3

Install pip from https://pip.pypa.io/en/stable/installing/

wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

Install the following with pip3:

sudo pip3 install setuptools --upgrade
sudo pip3 install ipython[all]

Change the python3 link back

sudo rm /usr/bin/python3
sudo mv /usr/bin/python3-old /usr/bin/python3

Create python3.5 kernel

cp -R ~/.ipython/kernels/python3 ~/.ipython/kernels/python3.5
sed -i -- 's/3/3.5/g' ~/.ipython/kernels/python3.5/kernel.json

After your done you can check by creating a Python 3.5 kernel Notebook and entering the following:

import sys

You should get the following response.

sys.version_info(major=3, minor=5, micro=0, releaselevel='final', serial=0)

*Edit: Reverted the default python3 to python3.4 but created a python3.5 kernel entry for the notebook. The reason for this is that changing the default python3 to python3.5 broke the apt-get updating process.

OR build from scratch, careful with symlinks as Ubuntu uses python3 symlink:

$ sudo apt-get install libssl-dev openssl
$ cd /opt
$ sudo mkdir python
$ cd python/
$ sudo wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
$ sudo tar xf Python-3.5.0.tgz
$ cd Python-3.5.0/
$ sudo ./configure
$ sudo make
$ sudo make install
$ sudo ln -fs /opt/python/Python-3.5.0/python /usr/bin/python

Expected outcome:

$ python3
Python 3.5.0 (default, Sep 21 2015, 12:25:06) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.