Install build dependencies
sudo apt-get build-dep python3.7Check latest python download link.
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xztar xvf Python-3.7.0.tar.xzcd Python-3.7.0/./configuremake# sudo make installsudo 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: