Installing the Latest Python 3.7 on Ubuntu 16.04 | 18.04

Python, a general-purpose programming language which is versatile and popular can easily be installed on Ubuntu via multiple methods… This post shows students and new users how to manually install the latest version of Python programming language on Ubuntu 16.04 | 18.04.

This post will also show you how to install Python via a third-party PPA which makes managing and updating to future versions easier from the PPA repository..

With Python, you can do almost anything like writing simple or advanced scripts, build and program robots and complicated machineries, develop websites and many more…. Python lets you work quicklyand integrate systems more effectively..

When you’re ready to install Python, continue with the steps below:

There are many ways to install Python on Ubuntu… Below are two methods that show you how to manually install from source code and via third-party PPA repository…

Method 1: Manually Installing Python

Some users may want manually install the latest version of Python on Ubuntu by building from the source code… To do that they will need to download the installer file and run the executable…

Before installing Python from its source code, you must first install some required packages that are needed to build Python from source.. To get these packages installed, run the commands below:

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

After installing the above packages, go and download the latest release’s source code from the Python download page using the following wget command..

cd /tmp

At the time of writing this post, 3.7.2 is the latest Python version… If you find a later version on the site, you can download it instead…

After downloading the package, run the commands below extract the file and install..

tar -xf Python-3.7.2.tar.xz
cd Python-3.7.2
./configure --enable-optimizations

Next start the building process using the make command.. Replace the #1 with the number of CPU cores on your system for faster build time… My machine has 1 CPU core, so I use the make command with -j 1 option…

make -j 1
sudo make altinstall

Do not use the standard make install as it will overwrite the default system python3 binary…

After that, Python should be installed and ready to use…

To test if Python is installed and ready to use, run the commands below

python3.7 --version

You should see an output similar to the one below:

Python 3.7.2
That’s how you install Python from its source

Method 2: Installing Python via PPA

If you quickly want to get the latest version of Python installed on Ubuntu and get future updates automatically, then you can install it from the below third-party PPA repository…

To do that, run the commands below to add the PPA.

First install Ubuntu software properties package if it’s not already installed on your system..

sudo apt update
sudo apt install software-properties-common

After that run the commands to add the PPA..

sudo add-apt-repository ppa:deadsnakes/ppa

Finally, run the commands below to install Python 3.7

sudo apt update
sudo apt install python3.7

That’s it!

You have learned how to manually install Python from its source code as well as how to add a third-party PPA to install the latest version of Python…

You may also like the post below:


  1. Hi,
    How if I remove the /tmp folder after running the make altinstall ?

    1. It it cleared automatically everyday by cron daily tasks

  2. test_conncurrrent_futures failed, a package in ubuntu is missing on install…

  3. I had to use sudo -H make altinstall with the -H because it was trying to overwrite .cache files with root files and that was not allowed

  4. how long does `make -j 1 && sudo make altinstall`? It seems like it’s taking forever. Kindly switch method 1 and 2. Cause I feel method 2 is way more efficient.

  5. In Method 2, do you manually change soft link to python3.7?
    python3 –version still shows old version.

  6. Please Reply:

    In Method 2, do you manually change soft link to python3.7?
    python3 –version still shows old version.

  7. Thanks for the build instructions, just built 3.8.6 on a ubuntu 16 server with 1/4GB memory in <15 minutes.
    You'll want to install pip like this:
    python3.8 -m pip install pyinotify
    python3.8 -m pip install –upgrade pip
    then use it like
    pip3.8 install Pillow

  8. also

    apt-get install libsqlite3-dev

    before the build. I did not notice the first time; since the Tmp files were still there, the rebuild was fast.

  9. Thank you for such a useful post. Hope this site to be more successful.

  10. Saved my day, had messed around trying to install python3.7 from deadsnakes but it couldn’t find the packages. Building from source worked like a charm and I can now run my scripts. Many thanks!

  11. method 2 was very good and easy to do.

    Thank you

    Prof. Wagner

  12. make -j $(nproc) will avoid the bla bla about cores 🙂

  13. I would also add libbz2-dev in the dependencies, as it’s a quite standard dependency for some packages. Thanks for the tutorial!

  14. sudo apt install python3.7

    gives error:
    E: Unable to locate package python3.7
    E: Couldn’t find any package by glob ‘python3.7’
    E: Couldn’t find any package by regex ‘python3.7’

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.