
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.
Before you begin, you need to:
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.
Install Python.
Confirm the installed Python version.
Your output should be similar to the one below:
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.
Confirm the installed pip version.
Your output should be similar to the one below:
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.
Run a test command.
The interpreter returns:
Exit the interactive shell.
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-venv package.
Create a new virtual environment. For example, example_env.
Activate the virtual environment.
The terminal prompt changes to indicate the active environment:
Install a sample package inside the virtual environment using pip. For example, requests.
Verify the installed package.
The output lists all packages installed in the virtual environment, including requests and its dependencies.
Deactivate the virtual environment to return to the system Python.
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.
0 Comments
Be the first to comment and share your perspective with the community.