How to Install Python 3.7 on Ubuntu 18.04 – Step‑by‑Step Guide
This tutorial walks you through two reliable methods for installing Python 3.7 on Ubuntu 18.04 LTS—using the deadsnakes PPA with APT and compiling from source—detailing prerequisite packages, exact commands, expected output, and verification steps.
Python is a versatile, high‑level language widely used for scripting, web development, data analysis, and more. This guide shows how to install Python 3.7 on an Ubuntu 18.04 LTS system using two approaches.
Method 1: Install via APT and the deadsnakes PPA
Ubuntu 18.04 ships with Python 3.6.9 by default. First, update the package index and ensure software-properties-common is installed so you can add PPAs.
$ sudo apt update
$ sudo apt install software-properties-commonAdd the deadsnakes repository and install Python 3.7:
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt install python3.7 -yThe installation output lists the new packages (e.g., libpython3.7-minimal, python3.7) and confirms successful setup. Verify the installation:
$ python3.7 -V
Python 3.7.7Method 2: Build and install from source
When you need a custom build, compile Python 3.7 from source. First, update the package index and install the required build dependencies.
$ sudo apt update
$ sudo apt install -y build-essential wget zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-devDownload the latest 3.7 source tarball, extract it, and configure the build with optimizations enabled.
$ wget https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tgz
$ tar -xf Python-3.7.7.tgz
$ cd Python-3.7.7
$ ./configure --enable-optimizationsAfter configuration completes, compile and install using make altinstall to avoid overwriting the system Python. $ sudo make altinstall The process installs binaries such as python3.7, pip3.7, and related tools. Verify the version:
$ python3.7 -V
Python 3.7.7Conclusion
Both methods successfully install Python 3.7 on Ubuntu 18.04 LTS. The APT approach is quick and handles dependencies automatically, while the source‑compilation method offers more control and can be adapted for newer patch releases. After installation, you can run Python 3.7 scripts and develop applications without affecting the system’s default Python interpreter.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
