Almost every Linux distribution comes with a version of Python included in the default arrangement packages. Only on occasion, due to some reasons, you might non find Python installed on an Ubuntu system.

Let's have a closer look at how you tin can install Python on Ubuntu, with a brief guide on updating the Python package likewise.

How to Check If Python Is Installed on Your System

Python is a powerful, loftier-level scripting linguistic communication that is used past many developers around the globe. The language is ideal for a variety of real-world applications including web evolution, web scraping, and penetration testing. You lot tin can even build a Telegram bot using Python.

To check if Python is installed on your organisation or non, open your terminal by pressing Ctrl + Alt + T. Type in "python" and press Enter.

If you come across the following output in your last, then you have Python installed on your calculator.

          Python iii.9.i (default, December 13 2022, xi:55:53)            
[GCC ten.2.0] on linux
Type "help", "copyright", "credits" or "license" for more than information.
>>>

This output provides information on the version of Python your system is running along with the current appointment and fourth dimension.

On the other paw, if you see an error that states "bash: python: control not found", then sadly your Ubuntu system doesn't take Python installed.

You lot can also check for the Python version by simply typing the post-obit command in your terminal.

          python --version        

The output will give you details on which version of Python is installed on your estimator.

How to Install Python on Ubuntu

Installing Python on a Linux-based operating system is easy. You tin get the latest version of Python on your Ubuntu machine from multiple sources. Here are some of the recommended means to do the same.

Install Python Using Apt

Apt, or Avant-garde Parcel Tool is the default packet manager that yous will find on Ubuntu. You tin download the Python bundle from the official Ubuntu repository. Here's how to do it.

  1. Open up your terminal past pressing Ctrl + Alt + T.
  2. Update your local system'south repository list by entering the post-obit command:
                  sudo apt-become update            
  3. Download the latest version of Python:
                  sudo apt-get install python            
  4. Apt will automatically detect the packet and install it on your computer.

Apply Deadsnakes PPA to Install Python iii on Ubuntu

If for some reason, yous are unable to download the Python packet from the official Ubuntu repository, you can try adding the Deadsnakes PPA to your system repository listing. PPAs or Personal Packet Archives are repositories that are especially designed for Ubuntu users.

By default, yous can't add together PPAs to your system's package lists. The "software-properties-common" packet provides you an efficient way to manage and add PPAs to your arrangement.

  1. Install the above-mentioned package on your arrangement past typing in the following command:
                  sudo apt-get install software-properties-common            
  2. Add the official Deadsnakes PPA link to your system's repository list:
                  sudo add-apt-repository ppa:deadsnakes/ppa            
  3. Update your system's package lists:
                  sudo apt-get update            
  4. Download the latest version of Python from the added PPA:
                  sudo apt-become install python3            

Since the Deadsnakes PPA has most every version of Python in its database, you can install older versions of Python equally well. Only replace the package proper name with the version of python you want to install on your calculator.

          sudo apt-get install python3.2
sudo apt-get install python3.three
sudo apt-go install python3.8

Install Python iii on Ubuntu From Source Code

Yous can as well download and build the latest version of Python from the official Python website. Although compiling the source code might seem a bit daunting to you at get-go, it'll get easier in one case you know the process.

  1. Update your system's local repository listing:
                  sudo apt-go update            
  2. Install supporting dependencies on your system with Apt:
                  sudo apt-get install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget            
  3. Make a new directory to store the Python source files:
                  mkdir /python && cd /python            
  4. Download the Python source code from the official FTP server:
                  wget https://world wide web.python.org/ftp/python/3.9.one/Python-three.nine.1.tgz            
  5. Extract the TGZ file that y'all just downloaded:
                  tar –xf Python-iii.9.ane.tgz            
  6. You lot demand to perform tests and optimizations before installing Python. This is important as it increases the execution of your code past 10-twenty percent:
                  cd python-3.9.1
    ./configure --enable-optimizations
  7. Build the bundle using the MakeFile present in the directory:
                  sudo make install            

After you've implemented these steps, check if Python has been installed on your computer past typing python --version in your terminal.

Note that Python modules are managed through PIP. PIP is a package management system that is used to download and add libraries from the Python Package Alphabetize. Installing Python PIP on your system is of import if you desire to use modules on your Python project.

Updating Python to the Latest Version

First of all, make sure that y'all have an outdated version of Python installed on your system. You can do this by enteringpython --version in your terminal. Note downward the version details.

Yous can find out what'southward the latest version available by searching the internet. A quick Google search on "python latest version" would suffice. If the ii version numbers don't match, then yous are probably running an outdated version.

Upgrading to the latest version is easy with Ubuntu's Advanced Bundle Tool. If you have installed Python on your system using Apt or the Deadsnakes PPA, enter the following control to download the latest version of Python:

          sudo apt-become install python        

You tin can as well employ the --only-upgrade flag to update your packages.

          sudo apt-become --only-upgrade install python        

For those who take compiled the source code on their own, you can head over to the Python FTP and grab a re-create of the latest version. You volition have to follow the steps all over again, nonetheless.

Running Python on Ubuntu

Python comes preinstalled on nigh every Linux system and is available on official distribution repositories as well. If yous still don't go Python installed on your computer, then you tin hands download it using Ubuntu'southward bundle manager.

The Python language is used in a diversity of different sectors, and its applications are plenty to demonstrate how powerful it is. Programming languages have become important equally because of the growing need for developers across industry.

10 Computer Programming Careers and Jobs That Are in High Need

Read Next

Nigh The Author