Easy methods to Set up Python in Ubuntu Linux (4 Strategies)

Typically, Python comes pre-installed in Ubuntu, but when it’s not accessible in your Linux distro

Typically, 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 just a few steps. In the event you’re a developer, Python is important to construct varied software program and web sites. Aside from that, numerous Ubuntu’s software program depends on Python, so you could have it for the graceful functioning of the OS. On that word, let’s go forward and learn to set up Python in Ubuntu.

Set up Python in Ubuntu (2022)

On this tutorial, now we have included 3 ways to get Python on Ubuntu. However earlier than that, let’s examine if Python is already put in in your system and replace it accordingly.

Be aware: We examined the instructions and strategies listed under on the newest model, i.e. Ubuntu 22.04 LTS and Ubuntu 20.04.

Examine If Python is Already Put in on Ubuntu

Prior to installing Python in Ubuntu, you need to examine whether or not it’s already put in in your system. This lets you replace the prevailing Python set up with out having to put in it from scratch once more. It also needs to come in useful for those who ever want to downgrade to a distinct Python model. With that stated, listed below are the steps to comply with.

See also  The right way to Use Apple Watch Low Energy Mode

1. First, open Terminal utilizing the “Alt + Ctrl + T” keyboard shortcut and run the under command. If the command offers an output with the model quantity, it means you have already got Python put in in Ubuntu. To exit Python’s setting, press “Ctrl + D”. In case you get an error message like “Command not discovered”, you don’t have Python put in. So transfer to the following technique to put in it.

python3

2. You can even run the under command to examine the Python model in your Ubuntu set up.

python3 --version
Check If Python is Already Installed in Ubuntu

3. If an older model of Python is put in, run the under command to replace Python to the newest model in your Linux distro.

sudo apt --only-upgrade set up python3
Check If Python is Already Installed in Ubuntu

Set up Python in Ubuntu from Official Repository

Python is obtainable 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. Right here is easy methods to do it.

1. Open Terminal in Ubuntu and run the under command to replace all of the packages and repositories.

sudo apt replace && sudo apt improve -y
Install Python in Ubuntu From Official Repository

2. Subsequent, set up Python in Ubuntu by working the under command. It will robotically set up Python in your machine.

sudo apt set up python3
Install Python in Ubuntu From Official Repository

Set up Python in Ubuntu from Deadsnakes PPA

Other than the official repository, you may as well pull newer variations of Python from Deadsnakes PPA, which is standard 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 actually work. Listed here are the steps to comply with.

See also  Methods to Obtain and Set up macOS 13 Ventura Developer Beta on Mac

1. Hearth up the Terminal utilizing the “Alt + Ctrl + T” shortcut and run the under command. That is wanted to handle your distribution and software program sources from unbiased distributors.

sudo apt set up software-properties-common
Deadsnakes PPA (Newer Versions)

2. Subsequent, 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
Deadsnakes PPA (Newer Versions)

3. Now, replace the bundle checklist and run the following command to set up Python.

sudo apt replace
sudo apt set up python3
Deadsnakes PPA (Newer Versions)

4. You can even select to set up a particular 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 nicely. Run the instructions within the following style:

sudo apt set up python3.12

or

sudo apt set up python3.11
Deadsnakes PPA (Newer Versions)

Construct Python in Ubuntu from the Supply Code

In the event you want to go the additional mile and construct Python instantly in Ubuntu from the supply code, you are able to do so. However keep in mind, it’s a barely lengthier course of and would possibly require greater than quarter-hour to compile Python, relying in your {hardware} specs. Listed here are the steps it’s worthwhile to comply with.

1. First, open the Terminal and run the under command to replace the packages.

sudo apt replace
Build Python in Ubuntu From Source Code

2. After that, run the following 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
Build Python in Ubuntu From Source Code

3. Subsequent, create a “python” folder and transfer to the stated folder. In the event you get a “Permission denied” error, run the command with sudo.

sudo mkdir /python && cd /python
Build Python in Ubuntu From Source Code

4. Following that, use wget to obtain the newest model of Python from the official web site. Right here, I’m downloading Python 3.12.0a1.

sudo wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0a1.tgz
Build Python in Ubuntu From Source Code

5. Now, extract the downloaded file utilizing the tar command and transfer to the extracted folder.

sudo tar -xvf Python-3.12.0a1.tgz
cd Python-3.12.0a1
  • Build Python in Ubuntu From Source Code
  • Build Python in Ubuntu From Source Code

6. After that, run the under command to activate optimizations earlier than constructing Python in Ubuntu. It will scale back the time for Python compilation.

./configure --enable-optimizations
Build Python in Ubuntu From Source Code

7. Lastly, execute the under command to construct Python in Ubuntu. It will take wherever between 10 to fifteen minutes to finish the method.

sudo make set up
Build Python in Ubuntu From Source Code

8. As soon as it’s achieved, run the python3 --version command to examine the Python model quantity. And you’re achieved.

Build Python in Ubuntu From Source Code

Set up or Replace Python in Ubuntu in 4 Straightforward Methods

So that is how one can set up Python in Ubuntu Linux. In the event you didn’t select a minimal setup throughout set up, you then seemingly have Python put in in your system. Then, you solely have to examine the model and replace the prevailing Python set up. Nonetheless, for those who don’t have Python put in, you possibly can comply with one of many three strategies described above to put in it immediately. Anyway, that’s all from us. If you wish to run Android apps in Linux with out an emulator, comply with our information for detailed directions. Lastly, when you’ve got any questions, tell us within the remark part under.

See also  How you can Obtain and Set up iOS 16 Developer Beta on iPhone