In this tutorial we’ll install the latest Python 3 on an Ubuntu 18.04 machine.
In this article, we upgrade to python 3.7 from python 3.6 and configure it as the default version of python. I was just trying to upgrade my python and I find it a little bit hard to do. Python 3.6 is the default version that comes with Ubuntu 18.04/18.10 But the latest version is Python 3.8. So it would be better to upgrade one major version. Apr 24, 2020 Logged into your Ubuntu 18.04 server as a sudo non-root user, first update and upgrade your system to ensure that your shipped version of Python 3 is up-to-date. Sudo apt update sudo apt -y upgrade Confirm installation if prompted to do so. Step 2 — Check Version of Python. Check which version of Python 3 is installed by typing: python3 -V.
Python is one of the fastest growing programming languages at the time of writing. It’s easy to learn, fast, and versatile. You can do almost anything with it, and it’s the most popular for machine learning.
Some of the most popular sites and applications are built using Python – Google, Youtube, Instagram, Pinterest and Spotify to name a few.
We’ll install the latest Python 3, on our machine, using two methods. One will be to install the pre-compiled version from the repositories, and the second will be to compile the latest version ourselves, from the source code.
Method #1 – Install the Latest Python 3 from Repositories
This method is the easier way to install the latest version of Python.
Step 1 – Prerequisites
Download Python 3.4
Before installing, first let’s perform all updates, and then check the version currently installed on your machine. To do this run one of the following commands:

To check if there are multiple versions installed, run the following command to view all versions:
If you want to install the latest version of Python 3 on your machine, run the following command:
Step 2 – Install the Python 3.x
If it’s already installed, then you can upgrade to the latest version by running:
Method #2 – Install the Latest Python 3 from Source Code
This method is more complicated and it takes more time. The advantage to installing Python 3 this way is that you control the installation and it can be more secure at times, depending where the package is downloaded from.
Step 1 – Prerequisites

First off, let’s update our package index.
For this method, we’ll need the tools and libraries to build the source for Python. To install them, run the following commands:
Step 2 – Download Python 3.x
Now we’ll need to download the latest version onto our machine. To do this, visit the official Python website, check the Downloads section and click to download Source code. There you’ll see something like Latest Python 3 Release – Python 3.x.x. Follow that link and scroll down to Files. What we want is the link to “Gzipped source tarball”.
At the time of writing, this is the source tarball download link `https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz`. Now let’s download it onto our machine, in `/usr/src`:
Next, unzip the tarball:
Step 3 — Install Python3.x
Now let’s configure the build and install the build. This will take a while because it will run tests that will optimize the binary to run faster.
Development
After it’s finished, then Python 3 should be installed.
Conclusion
Now you should have the latest version of Python 3 up and running. If you’ve encountered any issue installing it, then don’t hesitate to let us know in the comments or contact us.
Python 2.7 Install
If you’re looking for a reliable high performance Linux VPS to run your scripts, then check out our Linux KVM Plans. Our smallest plan provides you with 2GB RAM, 10GB SSD for only $5.99/mo.
