How to Install Python and pip on Ubuntu 26.04

Python is a general-purpose programming language used for web development, automation, data analysis, and system scripting. pip is the default package manager for Python that installs and manages third-party libraries from the Python Package Index (PyPI).
This article explains how to install Python and pip on an Ubuntu 26.04 server, test the installation with an interactive session, and set up isolated development environments using virtual environments.
Prerequisites
Before you begin, you need to:
- Have access to an Ubuntu 26.04 server instance as a non-root user with sudo privileges.
Install Python
Ubuntu 26.04 includes Python in the default APT repositories. The following steps install the latest available Python version and verify the installation.
Update the APT package index.
console$ sudo apt update
Install Python.
console$ sudo apt install python3 -y
Confirm the installed Python version.
console$ python3 --version
Your output should be similar to the one below:
Python 3.14.3
Install pip
pip enables installation of Python packages from PyPI and other repositories. The following steps install pip and verify the installed version.
Install the pip package manager.
console$ sudo apt install python3-pip -y
Confirm the installed pip version.
console$ pip3 --version
Your output should be similar to the one below:
pip 25.1.1 from /usr/lib/python3/dist-packages/pip (python 3.14)
Test Python
The Python interactive shell allows you to execute code directly in the terminal. The following steps verify that the Python interpreter is working correctly.
Open the Python interactive shell.
console$ python3Run a test command.
python>>> print("Hello, Python!")
The interpreter returns:
Hello, Python!Exit the interactive shell.
python>>> exit()
Create Virtual Environments
Virtual environments provide isolated Python installations where each project maintains its own set of dependencies without affecting the system-wide packages. The venv module is included with Python and creates lightweight virtual environments.
Install the
python3-venvpackage.console$ sudo apt install python3-venv -y
Create a new virtual environment. For example,
example_env.console$ python3 -m venv example_env
Activate the virtual environment.
console$ source example_env/bin/activate
The terminal prompt changes to indicate the active environment:
(example_env) user@server:~$Install a sample package inside the virtual environment using pip. For example,
requests.console$ pip install requests
Verify the installed package.
console$ pip list
The output lists all packages installed in the virtual environment, including
requestsand its dependencies.Deactivate the virtual environment to return to the system Python.
console$ deactivate
Conclusion
You have installed Python and pip on an Ubuntu 26.04 server and created an isolated virtual environment for managing project-specific dependencies. Virtual environments prevent package conflicts between projects and provide reproducible development setups. For more information, refer to the official Python documentation.