How to Install Python 3.9 on Ubuntu 24.04
Introduction
Before we begin talking about how to install Python 3.9 on Ubuntu 24.04, let's briefly understand – What is Python 3.9?
Python 3.9 presents a robust update to the renowned Python programming language, featuring advanced capabilities and enhancements for developers. This latest version introduces improved syntax, enhanced performance, and additional modules.
Notable features include refined dictionary operations, updated string functionalities, and more precise error handling. Python 3.9 streamlines coding tasks, promoting efficiency and readability in projects of all sizes.
In this tutorial, you will install Python 3.9 on Ubuntu 24.04 using PPA repository and office setup file. We will also address a few FAQs on how to install Python 3.9 on Ubuntu 24.04.
Advantages of Python 3.9
- Improved Type Hints: More expressive and easier to use, leading to better code quality and potential performance gains.
- Enhanced Pattern Matching: More concise and expressive way to handle complex data structures.
- Simplified Dictionary Operations: Easier to merge and update dictionaries using new operators.
- Performance Boost: Optimized built-in data structures and operations for faster execution.
- Streamlined Error Handling: Improved handling of multiple exceptions for better error management.
Method 1: Installing Python 3.9 on Ubuntu 24.04 by using the PPA repository
Follow the instructions below to install Python 3.9 on an Ubuntu system via the PPA repository.
Step 1: Update system packages
First, update the system packages in the Ubuntu 24.04 terminal by pressing CTRL+ALT+T
:
sudo apt update
Step 2: Install Additional dependencies
Install the necessary prerequisites by using the following command:
Step 3: Adding PPA repository
Add the deadsnakes
PPA repository to the system next. The simplest method for installing Python 3.9 is as follows:
sudo add-apt-repository ppa:deadsnakes/ppa
Let's continue with installing Python 3.9.
Step 4: Python 3.9 installation
Use this command to install Python 3.9 on Ubuntu 24.04:
sudo apt install python3.9 -y
Step 5: Validate Python Version
python3.9 --version
On our Ubuntu 24.04 system, we have successfully installed Python.
Let's try installing Python 3.9 using the second method.
Method 2: Python 3.9 installation on Ubuntu 24.04 using the official setup file
Follow the instructions listed below to install Python 3.9 using the official setup file on Ubuntu 24.04.
Step 1: Install additional dependencies
By running the following command, you can first install the additional dependencies:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev -y
Get the setup file in the next step.
Step 2: Downloading the Python 3.9 setup
The Official Python 3.9 setup file should be downloaded using the wget
command in the next step:
wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz
Step 3: Unzip Python 3.9 setup file
The Python 3.9 setup file should be unzipped as follows:
tar -xvf Python-3.9.7.tgz
Make use of the cd
command to navigate to the Python-3.9.7/
folder:
cd Python-3.9.7/
Step 4: Run ./configure
script
Run the ./configure"
script after opening the Python-3.9.7/
folder:
./configure --enable-optimizations
Step 5: Process Build compile configurations
Run the ./configure
script after opening the Python-3.9.7/
folder:
make
Step 6: Python 3 binaries installation
In order to install Python 3 binaries on the Ubuntu 24.04 system, use the command provided below:
sudo make altinstall
Step 7: Check out Python version
Verify Python's version to see if the installation was successful:
python3.9 --version
The method for deleting Python 3.9 from Ubuntu 24.04 is described in the section that follows.
How to remove Python 3.9 from Ubuntu 24.04
Use the following command to delete Python 3.9 on Ubuntu 24.04:
sudo apt remove python3.9 -y
We have successfully shown how to set up and take down Python 3.9 on Ubuntu 24.04.
FAQs to Install Python 3.9 On Ubuntu 24.04
Is Python 3.9 available in the default Ubuntu 24.04 repositories?
No, Python 3.9 is not included in the default repositories for Ubuntu 24.04; you need to use the Deadsnakes PPA.
How do I check the installed Python packages?
You can check installed packages with: python3.9 -m pip list
How can I check if Python 3.9 is already installed on Ubuntu 24.04?
Open a terminal and type python3.9 --version
. If Python 3.9 is installed, it will display the version number; otherwise, it will show an error.
What IDEs support Python 3.9?
Popular IDEs include PyCharm, VSCode, and Jupyter Notebook.
What should I do if I encounter permission errors?
Run the command with sudo
to gain the necessary permissions.
Note: Only use sudo
as a last resort when you're certain about the risks and have no other options.
What if I encounter "Command 'python3.9' not found" error after installation?
This error may occur if the Python executable is not in the system's PATH. Try specifying the full path to the Python 3.9 executable, or check your installation process.
Conclusion
We hope this detailed tutorial helped you understand how to install Python 3.9 on Ubuntu 24.04.
If you have any suggestions or queries, kindly leave them in the comments section.