How to Install Python on Ubuntu 26.04

How to install Python on Ubuntu 26.04

Python is a versatile programming language that works on nearly any system architecture, whether for web development or machine learning, and can be applied in many areas. Besides its flexibility, Python is also a language that’s pretty easy for newcomers to pick up, which is why it’s one of the most favored programming languages. A function in Python is a block of code designed to perform a specific task, either using built-in functions or custom-made functions. Python has various built-in functions, such as print() to print output, len() to calculate the length of an object, sum() to add elements, and input() to accept user input. In this article, we’ll walk you through how to install Python on Ubuntu 26.04

Installation Prerequisites

Conventions

# – given commands should be executed with root privileges either directly as a root user or by use of sudo command
$ – given commands should be executed as a regular user

Step 1. Log in to the VPS and Update the System

First of all, we need to log in to our Ubuntu 26.04 VPS through SSH:

ssh master@IP_Address -p Port_number

Replace “master” with a user that has sudo privileges or root if necessary. Additionally, replace “IP_Address” and “Port_Number” with your server’s respective IP address and SSH port number. Next, let’s make sure that we’re on Ubuntu 26.04. You can do that like this:

$ lsb_release -a

The command should return an output similar to this:

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu Resolute Raccoon
Release: 26.04
Codename: resolute

Before starting, you have to make sure that all Ubuntu packages installed on the server are up to date. You can do this by running the following commands:

$ sudo apt update -y

Step 2. Install Python

Ubuntu 26.04 ships Python 3.13 as the default version. You can verify this by executing the command below, and if it returns a value, it means Python3 is already installed on your system.

$ python3 --version

The output:

Python 3.13.9

Or, to see the complete details, we can run this command:

$ sudo apt show python3

The command will return an output like this:

Package: python3
Version: 3.13.7-1
Priority: important
Section: python
Source: python3-defaults
Origin: Ubuntu
Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com
Original-Maintainer: Matthias Klose doko@debian.org
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 85.0 kB
Provides: python3-profiler, python3-supported-max (= 3.13), python3-supported-min (= 3.13)
Pre-Depends: python3-minimal (= 3.13.7-1)
Depends: python3.13 (>= 3.13.7-1~), libpython3-stdlib (= 3.13.7-1)
Suggests: python3-doc (>= 3.13.7-1), python3-tk (>= 3.13.7-1~), python3-venv (>= 3.13.7-1)
Conflicts: python3-distutils
Replaces: python3-minimal (<< 3.1.2-2)
Homepage: https://www.python.org/
Task: cloud-minimal, minimal, server-minimal
Download-Size: 23.9 kB
APT-Manual-Installed: no
APT-Sources: http://id.archive.ubuntu.com/ubuntu resolute/main amd64 Packages
Description: interactive high-level object-oriented language (default python3 version)
Python, the high-level, interactive object oriented language,
includes an extensive class library with lots of goodies for
network programming, system administration, sounds and graphics.

This package is a dependency package, which depends on Debian's default
Python 3 version (currently v3.13).

To install Python packages, we can simply execute the command like: sudo apt install python3-[PACKAGE], for example:

$ sudo apt install python3-exif

To search python3 packages, simply run this command:

$ sudo apt search python3-*

The command will list all available python3 packages to install.

At the time of this writing, there is no option to install Python other than from the default Ubuntu 26.04 repository.

Step 3. Create a Simple Python App

In this step, we will create a simple Python application to calculate numbers. Let’s create a file now.

$ nano calculate.py

Paste the following into the file above

print("Simple Calculation")
num1 = int(input("Enter a number: "))
num2 = int(input("Enter another number to add: "))
total = num1 + num2

print("The value of the sum of two numbers is : ", total)

Save the file and exit from the editor.

Now, you can run the application with the command below.

$ python3 calculate.py

The command will ask you to type numbers twice.

Simple Calculation
Enter a number: 

Type a number, whatever you like, and you will be asked to type another one:

Enter another number to add:

Finally, the simple script will calculate the numbers, as shown below:

Simple Calculation
Enter a number: 24
Enter another number to add: 8123 
The value of the sum of two numbers is :  8147

Final Summary

That’s it all. You have learned how to install Python on Ubuntu 26.04.

Of course, you don’t have to install Python on Ubuntu 26.04 yourself if you have an active Python hosting service with us. In that case, you can simply ask our admins, sit back, and relax. Our admins will install and set up Python on Ubuntu 26.04 immediately, at no additional cost, along with many useful configurations and optimizations we can make for you. Managing Python is not just about the installation; we can help you optimize your Python installation if you have an active service with us.

If you like this post on how to install Python on Ubuntu 26.04, please share it with your friends or leave a comment below.

Leave a Comment