Ubuntu – How to install the latest Python 2.7.X or 3.X on Ubuntu

pythonsoftware installation

I want to install the latest Python tarball on Ubuntu, downloaded from http://python.org/download/.

Is this is a correct way to install?

make install

If not, how do I do that?

Best Answer

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:

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:

sudo checkinstall

Change version to whichever version you need (version=2.7.1 or version=3.6.0, for example).