First, install some dependencies:
sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Then download using the following command:
version=2.7.13 cd ~/Downloads/ wget https://www.python.org/ftp/python/$version/Python-$version.tgz
Extract and go to the directory:
tar -xvf Python-$version.tgz cd Python-$version
Now, install using the command you just tried, using
checkinstall instead to make it easier to uninstall if needed:
./configure make sudo checkinstall
version to whichever version you need (
version=3.6.0, for example).
Unless you really have a burning desire to compile it yourself, the preferred way is to use the DeadSnakes PPA to install versions of Python that aren't included by default:
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python2.7
Other versions, such as
python3.6, etc. are also available.