How to Install Python 3 in Ubuntu 20.04 / 22.04. Many people have seemingly become disenchanted with Microsoft’s line of products. Whether we’re talking about Windows or its collection of proprietary .NET programming languages, all their best features seem to be hidden behind paywalls.
Fortunately, there’s an open source counterpart for nearly every paid software product (or an opportunity to write your own). Ubuntu Linux and Python are two of the most popular open source properties in their categories (operating system and programming language). If you’re used to using Windows or Mac, migrating to a Linux distribution is challenging.
Where installing software development kits for NodeJS or Python is straightforward for Windows, this isn’t the case for many Linux Distros. So if you’re new to Ubuntu and you want to start coding with Python. Please follow this guide for step by step guide how to install Python 3 on Ubuntu 20.04/ 22.04.
What is Python?
All in all, python essentially allows engineers to worry less about syntax and focus more on solving problems. This makes it ideal for Data Science, , deep learning and artificial intelligence. Since Python supports a variety of programming paradigms (procedural (imperative), object oriented, functional, structured, and reflective), it accommodates different learning styles and approaches to coding. Furthermore, this makes it easier to transfer what you’ve learned from one programming language to Python. All in all, suitable for developers of all levels of experience and expertise.
But how do you install Python 3 in Ubuntu 20.04 or 22.04? At the time of this guide’s creation, Python 3.11.3 was the latest release. As such, the proceeding tutorials use it as an example.
How to Install Python On Ubuntu Tutorial
In some cases, python may already be installed on your system. Most Ubuntu installations come with Python pre-installed by default. As such, the first thing you must do is ensure that Python isn’t installed.
- Click on Activities. This opensa search field.
- Type Terminal into the search field.
- Select the Terminal option.
Once the terminal window is launched, verify the Python version by typing:
However, you may still have a version of Python installed, even if this command doesn’t execute successfully. To specifically check for Python 3, type the following code:
Once again, if Python 3 isn’t installed on your system, you should be greeted with an error message. However, if it is, it displays the Python version number. This means you’re all set to use Python on your computer. Although the version of Python that’s currently installed may be outdated. As such, you may still benefit from using the rest of this guide. So whether you don’t have Python installed on your computer or you’re using an outdated version, the next section shows you how to install Python 3 in Ubuntu:
Installing Python on Ubuntu
To successfully follow these instructions, you must first ensure that you have . Once that’s done you use the to install Python 3 from the (PPA). While you could use Ubuntu’s default repositories, Deadsnakes was specifically made to help users install Python on their computers. It contains the latest releases of Python, including nightly builds.
sudo apt update
- Hit Enter.
- Enter the following command into the terminal screen:
sudo add-apt-repository ppa:deadsnakes/ppa
- You are presented with a wall of text. Read through the text carefully, then hit the Enter key to continue. Ubuntu then take a few moments to install the Deadsnakes PPA.
- Once that’s done, refresh your repository lists again (
sudo apt update).
- Next, run the following command:
sudo apt install python3.11
- Follow the prompts on the screen, pressing the Y and/or Enter keys when necessary.
- Once the installation is complete, verify that it was successful by using the
It’s also a good idea to install the python-is-python3 package. It creates a symlink to the default Python command. This makes it easier for developers who have certain scripts or projects that rely on the Python (and not Python3) command. To install python-is-python3, refresh your Ubuntu repository lists and run the following command:
sudo apt-get install python-is-python3 -y
Please check the Python (3) version by running this command:
How to Uninstall Python from Ubuntu
Well, you may decide that you want to uninstall Python or its older versions from your system. Run the following command to check which versions of Python you have on your computer:
It results in something similar to this:
sudo apt-get remove python3.[version number]
Replace [version number] with the version of Python 3 you want to remove. For example:
sudo apt-get remove python3.10
Of course, you can’t completely remove Python from the latest versions of Ubuntu because they’re so closely linked. However, you still purge and eliminate any Python packages that are unnecessary with the use of the above command.
How to Install Python 3 in Ubuntu 20.04 / 22.04 Conclusion
The above guide explores How to install Python 3 in Ubuntu 20.04/ 22.04. As this guide mentions, Python may already be installed on your version of Ubuntu. The fact is Ubuntu (particularly ) uses Python for many of its important features. Thus, it’s not possible to completely separate or remove Python from Ubuntu. Regardless, the installed version of Python may not be the latest and it may not be accessible to you. Although updating or installing the latest version of Python is always a good idea.
So now that you’ve installed it, the next step is to master it. A good place to start (as a beginner) is learning how to compile and run Python applications using a simple . Nevertheless, we hope that you’ve found this guide helpful. Please leave a comment down below if you have any questions, corrections, or queries. As always, thank you for reading.