How To

Install Python 3.9: Easy Ubuntu 20.04 Setup Guide

If you’re looking to Install Python 3.9 on Ubuntu 20.04, there are two reliable methods available. You can either use a trusted package repository for a quick installation or compile Python from source to gain access to the latest features and customization options.

Python remains one of the most widely used programming languages for web development, automation, artificial intelligence, data science, and system administration. Python 3.9 introduced several improvements, including enhanced dictionary operations, new string methods, and better time zone support, making it a popular choice among developers.

In this guide, you’ll learn how to install Python 3.9 on Ubuntu 20.04 using both methods.

Why Install Python 3.9 on Ubuntu?

Ubuntu 20.04 ships with an older Python version by default. While it works well for many applications, developers often need newer Python releases to access updated features, improved performance, and better compatibility with modern frameworks.

Installing Python 3.9 alongside the system version allows you to use the latest capabilities without affecting critical Ubuntu components.

Install Python 3.9 Using APT Repository

The easiest way to install Python 3.9 is through a trusted third-party repository that provides updated Python packages for Ubuntu.

First, update your package list and install the required tools:

sudo apt updatesudo apt install software-properties-common

Next, add the repository that contains Python 3.9 packages:

sudo add-apt-repository ppa:deadsnakes/ppa

After enabling the repository, install Python 3.9:

sudo apt updatesudo apt install python3.9

Verify the installation:

python3.9 --version

If everything is successful, Ubuntu will display the installed Python version.

Install Python 3.9 from Source Code

Developers who want maximum control over their Python installation can build it directly from source code.

Start by installing the necessary build dependencies:

sudo apt updatesudo apt install build-essential zlib1g-dev libncurses5-dev \libgdbm-dev libnss3-dev libssl-dev libreadline-dev \libffi-dev libsqlite3-dev wget libbz2-dev

Download the Python source archive and extract it:

wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgztar -xf Python-3.9.1.tgz

Move into the extracted directory:

cd Python-3.9.1

Configure the build process:

./configure --enable-optimizations

Compile Python:

make -j $(nproc)

Finally, install it without replacing Ubuntu’s default Python version:

sudo make altinstall

Confirm the installation:

python3.9 --version

Verify Your Python Environment

After you install Python 3.9, it’s a good idea to ensure the interpreter is functioning correctly.

Run:

python3.9

You should enter the Python interactive shell, where you can execute commands and test functionality immediately.

For development projects, consider creating isolated virtual environments to manage dependencies efficiently and avoid package conflicts.

Conclusion

Choosing to Install Python 3.9 on Ubuntu 20.04 gives developers access to modern language features, improved performance, and broader compatibility with current applications. Whether you use the faster repository-based method or compile from source for greater flexibility, both approaches provide a dependable way to Install Python 3.9 while keeping your Ubuntu system stable and secure.

Cyber Defence

Recent Posts

Install phpMyAdmin on Ubuntu 18.04 with Apache: Setup Guide

phpMyAdmin is a free, open-source PHP application that provides a browser-based interface for managing MySQL and…

1 day ago

Install Zabbix on Ubuntu 18.04: Server Setup with MySQL Backend

Zabbix is a mature open-source infrastructure monitoring platform that collects metrics from network devices, servers, virtual…

1 day ago

Install Gradle on Ubuntu 18.04: Set Up OpenJDK and Environment

Gradle is a powerful open-source build automation tool used primarily for Java, Kotlin, Groovy, and Android…

1 day ago

Install TeamViewer on Ubuntu 18.04: Download the .deb and Set Up

TeamViewer is a proprietary cross-platform remote access application for remote control, desktop sharing, file transfer, and online meetings. It is one of the most widely used remote support tools in the world, available for Windows, macOS, Linux, iOS, and Android. TeamViewer is not included in the Ubuntu repositories because it is proprietary software. This guide covers how to install TeamViewer on Ubuntu 18.04 using the official .deb package. The same steps apply to Ubuntu 16.04, Debian, Linux Mint, and Elementary OS. <strong>Prerequisite:</strong>&nbsp;You&nbsp;need&nbsp;sudo&nbsp;access. Install TeamViewer on Ubuntu: Download the .deb Package Download the official TeamViewer .deb package. The _amd64.deb suffix indicates this package is for 64-bit x86-64 systems. For ARM-based machines, download the appropriate package from the TeamViewer Linux downloads page: bashwget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb Install the package using apt. The ./ prefix tells apt this is a local file path, not a package name from the repositories:…

1 day ago

Install Nagios Core on Ubuntu 18.04: Build from Source Guide

Nagios is one of the most widely used open-source infrastructure monitoring systems in the world. It…

1 day ago

Install Laravel on Ubuntu 18.04 with Composer: Setup Guide

Laravel is an open-source PHP web application framework built around an expressive, developer-friendly syntax. It is…

2 days ago