20.05.2026

How to Install Python on Ubuntu 26.04: Step-by-Step Guide with pip & Virtual Environment

Getting Python running on a fresh Ubuntu 26.04 server is usually one of the first things you do before starting any real development work. Whether you’re deploying a web app, running automation scripts, or setting up a backend service, a clean Python environment is the foundation.

On Ubuntu, the process is usually quick, but there are a few things worth doing properly from the start — especially if you plan to work with virtual environments or deploy projects to production.

Before you start: check if Python is already installed

Most Ubuntu 26.04 installations already include Python 3. The first step is simply to confirm it:

python3 --version

If you see a version number, Python is already available. If not, you’ll install it in the next step.

Install Python on Ubuntu 26.04

Start by updating your package list. This avoids dependency issues later:

sudo apt update && sudo apt upgrade -y

Now install Python 3:

sudo apt install python3 -y

Check the installation:

python3 --version

At this point, Python is ready to use.

Install pip (you will need it almost immediately)

If you plan to install any Python libraries (Flask, Django, requests, etc.), pip is required.

Install it with:

sudo apt install python3-pip -y

Verify:

pip3 --version

Set up a proper development environment

Using the system-wide Python installation for application development is discouraged because it couples project dependencies with OS-level packages, which can lead to version conflicts and unstable behavior during updates. A more reliable approach is to isolate each project in its own environment using Python virtual environments.

Start by installing the required system packages for environment management and package compilation:

sudo apt install python3-venv python3-dev build-essential -y

This provides:

Real-world example: setting up a small Python project

Let’s say you want to quickly test a simple web service on your Ubuntu server.

After activating your virtual environment:

pip install flask

Create a file:

nano app.py

Add a minimal Flask app:

from flask import Flask

app = Flask(name)

@app.route("/")
def home():
return "Python is running on Ubuntu 26.04"

if name == "main":
app.run(host="0.0.0.0", port=5000)

Run it:

python app.py

Now you have a working Python service running on your server. This is often the first step before deploying something more serious.

Why developers use Serverspace for Python projects

When you’re working with Python on Ubuntu, local machines are not always the best option — especially if you’re testing deployments, APIs, or background services.

With Serverspace, you can spin up a ready Ubuntu VPS in minutes and work exactly like you would on a production server.

Typical workflow looks like this:

If you’re working with web apps or automation tools, it’s often easier to develop directly on a VPS instead of syncing between local and server environments.

You can explore more about cloud infrastructure and deployment options here:
https://serverspace.us/services/cloud-servers/

Common issues (and what actually fixes them)

Python command not found
On Ubuntu, the command is usually python3 instead of python.

If you want python to point to python3:

sudo apt install python-is-python3

pip is installed but not working
This usually happens when pip is installed for a different Python version. Try:

python3 -m pip --version

Virtual environment not activating
Most of the time it’s just missing permissions or wrong folder. Make sure you are inside your project directory:

cd my-project
source venv/bin/activate

Old Python version from repositories
Ubuntu repositories sometimes lag behind official Python releases. If you need a newer version, consider:

compiling from source
using a version manager like pyenv

Conclusion

Installing Python on Ubuntu 26.04 is straightforward, but the real value comes from setting it up properly — using pip, isolating environments, and keeping projects structured.

Once your environment is ready, you can move on to building APIs, automation scripts, or full backend services without worrying about system conflicts.

If you’re deploying to production or testing real-world workloads, using a VPS from Serverspace is often the most practical next step.