Home Python How to Install Python on Ubuntu Linux

How to Install Python on Ubuntu Linux

Python is a high-level programming language that is continually taking the interest of many users in the Linux community. The Python general-purpose programming language is in the top ranks with other popular programming languages due to its applicability in web and software development.

Also, with the modern world questing for individuals with mastery in design, machine learning, and analytics, Python programming language is an ideal alternative for such a career path due to the following programmatic traits:

  • Python programming language is versatile – Whether you want to major in desktop-based applications, mobile-based applications, web-based applications, or even data visualization, Python fits the profile of making such career moves possible.
  • Python programming language adheres to simple syntax rules – The English-like syntax of Python makes it a straightforward programming language, making it easy for users to interpret each line of code. Therefore, you can easily debug your own code when errors occur.
  • Python programming language has a growing community – The open-source nature of Python has led to a thriving online community in support of its use and applicability. These users contribute useful developed Python libraries, learning materials, and tutorials that empower other users.
  • Python programming language is easy to learn and master – Unlike other programming languages with slightly complicated footprints, Python is perfect for beginners/newbies that are yearning to master a new programming language.

This article will walk you through installing and setting up Python programming language on an Ubuntu Linux distribution.

Install Python on Ubuntu Using APT

With this approach, you only need to acknowledge the use of the Ubuntu package manager (APT), which is a package manager for searching, retrieving, and installing supported packages for your distribution.

The latest Python version is 3.10.x. We are going to query the existence of the Python package via our Ubuntu package manager with the following command:

$ apt search python3.10 
Search Python Package in Ubuntu
Search Python Package in Ubuntu

Since we have confirmed that the Python3.10.x version does exist, the next step is to execute the Ubuntu installation command to retrieve and install it on our system:

$ sudo apt install python3.10
Install Python in Ubuntu
Install Python in Ubuntu

If you did not have Python already installed on your system, the above command will do the necessary.

Using the apt package manager to install Python on your Ubuntu distribution is a recommended approach since you will be able to upgrade to the latest Python version (by running a system update command) once its official release is announced.

Confirm the installed Python version:

$ python3 -V
Check Python in Ubuntu
Check Python in Ubuntu

Install Python on Ubuntu from the Source

First, update the Ubuntu system and then install system dependencies.

$ sudo apt update 
$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

Next, download the latest Python source release using the following wget command and install it as shown.

$ wget https://www.python.org/ftp/python/3.10.7/Python-3.10.7.tar.xz
$ tar -xf Python-3.10.7.tar.xz
$ cd Python-3.10.7
$ ./configure
$ make 
$ sudo make install
$ python3 -V

Install Python Modules in Ubuntu

With Python successfully installed, you should now be able to install and use various Python modules via PIP (Python Package Manager).

$ sudo apt install python3-pip         [On Debian, Ubuntu and Mint]
$ sudo yum install python3-pip         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a dev-lang/pip          [On Gentoo Linux]
$ sudo apk add py3-pip                 [On Alpine Linux]
$ sudo pacman -S python-pip            [On Arch Linux]
$ sudo zypper install python3-pip      [On OpenSUSE]    

To install a Python module, implement the following command syntax:

$ python3 -m pip install module_name

For more usage of the Python pip command, read our article – Python PIP Cheat Sheet for Linux.

With Python installed on your Ubuntu system, you should be able to make a career out of a hobby.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.