Install Latest Python (3.7) on Ubuntu (Build From Source)

August 29, 2018

Install build dependencies

sudo apt-get build-dep python3.7

Check latest python download link.

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xvf Python-3.7.0.tar.xz
cd Python-3.7.0/
./configure
make
# sudo make install
sudo make altinstall 

NOTE: make install can overwrite or masquerade the python3 binary. make altinstall is therefore recommended instead of make install since it only installs exec_prefix/bin/pythonversion.

Alternatively, you can install Python via apt-get.

The more flexible and safer solution would be via pyenv.

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.