Every update of Python has performance improvements over the earlier version. Python 3.9 rolls in two significant improvements that increase performance without requiring any modifications to existing code.
It has improved the Python installation on Ubuntu LTS and makes it faster and easier.
Python 3.9.1 is the latest major release of the Python programming language. It includes several new features and optimizations and has around 282 changes since 3.9.0 which is a significant amount. 3.9.1 is the first version of
Python that supports macOS 11 Big Sur. With XCode 11 and later it is now possible to create “Universal 2” binaries that run on Apple Silicon.
Some New Major Features of Python 3.9 as Compared to 3.8:
- Module State Access from C Extension Methods
- Flexible High Performant PEG-Based Parser
- Dictionary Update and Merge Operators
- New String Functions to Remove Prefix and Suffix
- Support for IANA time zone In Date Time
- Ability to Cancel Concurrent Futures
- Consistent Package Import Errors
- Random Bytes Generation
- Relaxing Grammar Restrictions on Decorators
How to Install Python 3.9 on Ubuntu 20.04 LTS
This tutorial teaches users how to install Python 3.9 on Ubuntu 20.04. Python, which is a general-purpose programming language, versatile and popular can simply be installed on Ubuntu through various methods.
Python 3.9, the latest release brings several unique features like, position-only parameter, assignment expression – which assigns values to variables as part of a larger expression, f-strings support, and many more.
Writing simple or advanced scripts, building, and programming robots and complicated machinery, developing websites, and many more, all can be easily accomplished with the help of Python.
It also allows you to work quickly and integrate systems more efficiently.
To install Python, proceed with the steps mentioned below:
There are several ways to install Python on Ubuntu. Here are the two methods that show you how to manually install from source code and through a third-party PPA repository.
Also, Read – 9 Best Linux Distros for Beginners & Programmers
Method 1: Manually Installing Python
There are users that want to manually perform the latest version of Python installation on Ubuntu by designing from the source code. To accomplish this, they need to download the installer file and run the executable.
Before installing Python from its source code, you need to install some required packages first that are required to create Python from the source. To get those packages installed, run these commands:
sudo apt update sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
After installing these packages, download the latest release’s source code from the Python download page using the following wget command.
cd /tmp wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
If you find the latest version on the site, you can download it instead.
After downloading the package, run the command below to extract the file, and install it.
tar -xf Python-3.9.0.tgz cd Python-3.9.0 ./configure --enable-optimizations
Next, begin with the building process by applying the make command. Replace the #4 with the number of CPU cores on your machine for faster build time.
Suppose if my machine has 4 CPU cores, so use the make command with the -j 4 option.
make -j 4 sudo make altinstall
Don’t use the standard make install because it overwrites the default operation with python3 binary.
Now, Python installation on Ubuntu is ready to use.
To check whether the Python is installed correctly and is ready to use, run the commands below:
You should notice a similar output as below:
That’s how you can install Python from its source.
Method 2: Python Installation on Ubuntu via PPA
This is the second method, if you instantly want to get the latest version of Python installation on Ubuntu and also receive future updates automatically, then you can install it from the following third-party PPA repository.
To accomplish this, you need to run the commands below to add the PPA.
Start by installing the Ubuntu software attributes package if you don’t have it on your system.
sudo apt update sudo apt install software-properties-common
Next, run the commands to add the PPA.
sudo add-apt-repository ppa:deadsnakes/ppa
Lastly, run the commands below to install Python 3.9
sudo apt update sudo apt install python3.9
Also, Read – Python 3.9 New Features Released Highlights
Python makes it easy to manage common data types, and Python 3.9 continues this expertise with newly added features for strings and dictionaries.
The above article explained how to install Python 3.9 on Ubuntu 20.04 LTS. Install and start your programming today.