How do I Install Python in Ubuntu Linux (4 Methods) (4 Methods).
Generally, Python comes pre-installed in Ubuntu, but when it’s not accessible in your Linux distro for some purpose, you possibly can set up Python in Ubuntu in a couple of steps. If you’re a developer, Python is crucial to construct varied software program and web sites. Other than that, a number of Ubuntu’s software program depends on Python, so you need to have it for the graceful functioning of the OS. On that observe, let’s go forward and discover ways to set up Python in Ubuntu.
Install Python in Ubuntu (2022)
In this tutorial, we’ve included 3 ways to get Python on Ubuntu. But earlier than that, let’s test if Python is already put in in your system and update it accordingly.
Note: We examined the instructions and strategies listed under on the most recent model, i.e. Ubuntu 22.04 LTS and Ubuntu 20.04.
Check If Python is Already Installed on Ubuntu
Before you put in Python in Ubuntu, it is best to test whether or not it’s already put in in your system. This permits you to update the present Python set up with out having to put in it from scratch once more. It must also turn out to be useful in the event you ever want to downgrade to a unique Python model. With that stated, listed below are the steps to comply with.
1. First, open Terminal using the “Alt + Ctrl + T” keyboard shortcut and run the under command. If the command provides an output with the model quantity, it means you have already got Python put in in Ubuntu. To exit Python’s surroundings, press “Ctrl + D”. In case you get an error message like “Command not found”, you don’t have Python put in. So transfer to the subsequent technique to put in it.
python3

2. You may run the under command to test the Python model in your Ubuntu set up.
python3 --version

3. If an older model of Python is put in, run the under command to update Python to the most recent model in your Linux distro.
sudo apt --only-upgrade set up python3

Install Python in Ubuntu from Official Repository
Python is offered in Ubuntu’s official repository, so that you don’t should do a lot apart from execute a easy command to seamlessly set up it in your system. Here is how to do it.
1. Open Terminal in Ubuntu and run the under command to update all of the packages and repositories.
sudo apt update && sudo apt improve -y

2. Next, set up Python in Ubuntu by working the under command. This will robotically set up Python in your machine.
sudo apt set up python3

Install Python in Ubuntu from Deadsnakes PPA
Apart from the official repository, you can even pull newer variations of Python from Deadsnakes PPA, which is in style for internet hosting new and outdated variations of Python. If Ubuntu’s official repository (APT) was unable to put in Python in your system, this could definitely work. Here are the steps to comply with.
1. Fire up the Terminal using the “Alt + Ctrl + T” shortcut and run the under command. This is required to handle your distribution and software program sources from impartial distributors.
sudo apt set up software-properties-common

2. Next, run the under command to add Deadsnakes PPA to Ubuntu’s repository. When prompted, press Enter to proceed.
sudo add-apt-repository ppa:deadsnakes/ppa

3. Now, update the package deal record and run the subsequent command to set up Python.
sudo apt update sudo apt set up python3

4. You may select to set up a selected model (outdated or new) of Python from Deadsnakes PPA. It additionally hosts nightly builds of Python (experimental), so you possibly can set up them as effectively. Run the instructions within the following trend:
sudo apt set up python3.12
or
sudo apt set up python3.11

Build Python in Ubuntu from the Source Code
If you want to go the additional mile and construct Python straight in Ubuntu from the supply code, you are able to do so. But keep in mind, it’s a barely lengthier course of and may require greater than quarter-hour to compile Python, relying in your {hardware} specs. Here are the steps that you must comply with.
1. First, open the Terminal and run the under command to update the packages.
sudo apt update

2. After that, run the subsequent command to put in the required dependencies to construct Python in Ubuntu.
sudo apt set up build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

3. Next, create a “python” folder and transfer to the stated folder. If you get a “Permission denied” error, run the command with sudo
.
sudo mkdir /python && cd /python

4. Following that, use wget
to obtain the most recent model of Python from the official web site. Here, I’m downloading Python 3.12.0a1.
sudo wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0a1.tgz

5. Now, extract the downloaded file using the tar
command and transfer to the extracted folder.
sudo tar -xvf Python-3.12.0a1.tgz cd Python-3.12.0a1
6. After that, run the under command to activate optimizations earlier than constructing Python in Ubuntu. This will scale back the time for Python compilation.
./configure --enable-optimizations

7. Finally, execute the under command to construct Python in Ubuntu. This will take anyplace between 10 to fifteen minutes to finish the method.
sudo make set up

8. Once it’s finished, run the python3 --version
command to test the Python model quantity. And you’re finished.

Install or Update Python in Ubuntu in 4 Easy Ways
So that is how one can set up Python in Ubuntu Linux. If you didn’t select a minimal setup throughout set up, then you definately seemingly have Python put in in your system. Then, you solely have to test the model and update the present Python set up. However, in the event you don’t have Python put in, you possibly can comply with one of many three strategies described above to put in it instantly. Anyway, that’s all from us. If you need to run Android apps in Linux with out an emulator, comply with our information for detailed directions. Finally, in case you have any questions, tell us within the remark part under.
Check out more article on – How-To tutorial and latest highlights on – Technical News