Original Answer: https://raspberrypi.stackexchange.com/questions/54365/how-to-download-and-install-python-3-5-in-raspbian
GET DEPENDANCIES:
$ sudo apt-get install build-essential libc6-dev
$ sudo apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev
$ sudo apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
$ sudo apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
DOWNLOAD:
$ cd $HOME
$ wget https://www.python.org/ftp/python/*ver*/Python-*ver*.tgz
# it is faster to download on PC and transfer to pi with FileZilla
$ tar -zxvf Python-*ver*.tgz
COMPILE:
$ cd Python-*ver*
$ ./configure # 3 min 13 s
# We have 4 processors, so let's use 4 threads
$ make -j4 # 8 min 29 s
$ sudo make install # ~ 4 min
$ sudo reboot
TEST:
$ cd
$ python3 --version
# output: "Python *ver*"
$ pip3 list
# output:
# pip (8.1.1)
# setuptools (20.10.1)
# You are using pip version 8.1.1, however version 8.1.2 is available.
# You should consider upgrading via the 'pip install --upgrade pip' command.