How To Install Python 3 on Ubuntu 16.04 LTS

Install Python 3 on Ubuntu 16.04 LTS

In this tutorial, we will show you how to install and configure Python 3 on Ubuntu 16.04 LTS. For those of you who didn’t know, Python is a versatile and powerful programming language widely used for web development, data analysis, machine learning, and automation tasks. While Ubuntu 16.04 LTS comes with Python 3 pre-installed, it may not be the latest version, and you may need to update or install a specific version to meet your project requirements.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Python 3 programming language on a Ubuntu 16.04 (Xenial Xerus) server.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 16.04 (Xenial Xerus).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Python 3 on Ubuntu 16.04 LTS

Step 1. Before proceeding with the Python installation, it’s essential to ensure that your Ubuntu system is up-to-date. Open the terminal and run the following commands to update the package lists and upgrade installed packages:

sudo apt-get update
sudo apt-get upgrade

This step ensures that you have the latest security patches and bug fixes, which can prevent potential issues during the installation process.

Step 2. Installing Python 3.

  • Method 1. Install Python 3.6 on Ubuntu 16.04 from PPA.

You can install Python 3.6 on Ubuntu 16.04  using this PPA:

sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt update
sudo apt install python3.6

You can check the Python version on Ubuntu from the command line:

python --version
  • Method 2. Installing Python 3.6 on Ubuntu 16.10 from Repository

Use the following command to install Python 3:

sudo apt update
sudo apt install python3.6

Then check the Python version:

python3.6 -V
  • Method 3. Compile and Install Python 3.6 on Ubuntu 16.04

First, we need to install some build dependencies using the commands below:

sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Then, download Python 3.6 from the source:

wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tar.xz
tar xvf Python-3.9.9.tar.xz

Now cd into the source directory, configure the built environment and install:

cd Python-3.9.9/
./configure
sudo make altinstall

Once the process is complete, we can check the version of Python 3 that is installed in the system by typing:

python3.9

Congratulations! You have successfully installed Python. Thanks for using this tutorial for installing Python programming language on the Ubuntu 16.04 LTS  (Xenial Xerus) system. For additional help or useful information, we recommend you check the official Python website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save

r00t is a Linux Systems Administrator and open-source advocate with over ten years of hands-on experience in server infrastructure, system hardening, and performance tuning. Having worked across distributions such as Debian, Arch, RHEL, and Ubuntu, he brings real-world depth to every article published on this blog. r00t writes to bridge the gap between complex sysadmin concepts and practical, everyday application — whether you are configuring your first server or optimizing a production environment. Based in New York, US, he is a firm believer that knowledge, like open-source software, is best when shared freely.

Related Posts