How to Install Python on Ubuntu 18.04 Bionic Beaver

Install Python on Ubuntu 18.04

In this article, we will have explained the necessary steps to install and configure Python on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Python is one of the most popular programming languages in the world. With its simple and easy to learn syntax Python is a great choice for beginners and experienced developers. Python is quite a versatile programming language, you can use it to do almost anything you want, write small scripts, build games, develop websites and many more.

Install Python on Ubuntu

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade
sudo apt install software-properties-common

Step 2. Install Python on Ubuntu.

  • Installing Python 3.7 on Ubuntu with apt:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7

Confirm the installation and check the version of Python by entering the following command:

$ python3.7 --version
Python 3.7.3
  • Installing Python 3.7 on Ubuntu from Source:
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

Now, download the latest releases source code from the Python download page:

wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
tar -xf Python-3.7.3.tar.xz
cd Python-3.7.3
./configure --enable-optimizations

Start the Python build process using make:

make -j 8
sudo make altinstall

Confirm the installation and check the version of Python by entering following command:

$ python3.7 --version
Python 3.7.3

That’s all you need to do to install Python on Ubuntu 18.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.