Python is a very popular High-Level programming language that focuses on improving code reliability, developer productivity, and runtime performance. It is commonly used for Website Development, Data Analysis, and Data Visualization. Python’s significant features make it a preferred choice among Ubuntu users for scripts and tool development.
This article focuses on the installation procedure of Python on the latest Ubuntu 22.04 version.
How to Install Python on Ubuntu 22.04?
Python can be installed by Two Methods:
- Using the PPA Repository.
- Using Official Setup File.
Method 1: Installing Python on Ubuntu 22.04 Using the PPA Repository
The PPA (Personal Package Archive) repository hosts software packages that are built and developed by individuals as open-source. The steps below explain the installation procedure of Python using the PPA Repository.
Step 1: Updating System Packages
Before installing Python, ensure that the system packages are up to date using the command below:
Now use the command to upgrade these packages:
Step 2: PPA Repository
Add the PPA Repository before installing Python. For this purpose, execute the below-stated “sudo” command:
It will ask for the confirmation of adding the repository, Press “Enter” to proceed further:
Once the Repository is added, it will inform you by saying the package lists are read:
Step 3: Installing Python
Install Python using the command below:
“3.9” is the Python version. You can install any version according to your needs.
Step 4: Validate Python
Execute the command below to validate the Python installation and its version:
This is how you can install Python using the PPA Repository.
Method 2: Installing Python on Ubuntu 22.04 Using the Official Setup File
Python can also be installed in Ubuntu 22.04 using the Official Setup file of Python. Follow the steps listed below to install Python using Official Setup.
Step 1: Installing Dependencies
Before installing Python using the setup file, add the following additional dependencies one by one for Ubuntu to install it:
Install the “zlib1g-dev” and “libncurses5-dev” now:
Now install the “libsqlite3-dev”, “libnss3-dev”, and “libffi-dev” libraries:
Once downloaded, install the “libgdbm-dev”, “libreadline-dev”, and “libssl-dev”, and using wget install the “libbz2-dev” libraries.
Step 2: Download Setup File
Now, using “wget” download the Python Setup File using the command:
The Python Setup File will be downloaded and saved:
Step 3: Extract the Setup File
Once the setup file is downloaded, extract it now using the command:
Step 4: Navigate to the Folder
Navigate to the folder where Python is extracted using the “cd” command:
Step 5: Run Script
When you’re inside the Python folder, run the “./configure” script:
Step 6: Process Compile Configurations
Run the command to process the build compile configuration inside the folder:
It will take some time, wait for it to be completed:
Step 7: Installing Binaries
To install Python Binaries, use the command:
It will install binaries like Pip:
Step 8: Validating Python
Use the command below to validate the Python Version:
This is the process of utilizing the Official Setup File for downloading and installing Python in Ubuntu 22.04.
How to Uninstall Python on Ubuntu 22.04?
If Python is no longer needed, you can uninstall it to free up some disk space. For this purpose, execute the given command:
This will remove all the packages installed in Python on Ubuntu:
That’s all about installing and uninstalling Python on Ubuntu 22.04.
Conclusion
In Ubuntu 22.04, Python can be installed either by using the PPA repository or using Python’s official setup file. Users can verify the existence of Python on their Ubuntu operating system by executing the “python 3.9 –version” command. To uninstall Python from Ubuntu 22.04, use the “sudo apt remove python 3.9” command. This article showcased the process for installing Python on Ubuntu 22.04 using two methods; Using the PPA Repository, and Installing Python using the Official Setup File.