Skip to content
Runbook

Install Python on Ubuntu / Debian

General-purpose programming language and runtime, batteries included.

Runtimelanguageruntimescriptinginterpreter

Installation

Python 3 + pip + venv · apt
sudo apt update
sudo apt install -y python3 python3-pip python3-venv

Ubuntu/Debian split pip and venv into separate packages.

Verify the installation

Verify
python3 --version

Important files

TypePathDescription
binary/usr/bin/python3System Python 3 interpreter managed by APT.

Command-line tools

  • python3The Python 3 interpreter.
  • pip3Package installer for Python.
  • venvVirtual-environment module (requires the python3-venv package).

Uninstall

Uninstall pip/venv
sudo apt purge -y python3-pip python3-venv
sudo apt autoremove -y

Do not remove python3 itself: the system depends on it.

Good to know

  • Never uninstall or replace the system python3: many OS tools depend on it.
  • On Debian/Ubuntu, pip and venv are separate packages (python3-pip, python3-venv).
  • For a newer interpreter, use the deadsnakes PPA or pyenv rather than replacing the system one.

Installation on Ubuntu / Debian

Python 3 is usually preinstalled, but pip and venv are not. sudo apt install -y python3 python3-pip python3-venv adds them. The interpreter is /usr/bin/python3.

Do not touch the system Python

Many distribution tools rely on /usr/bin/python3. Never replace it or run sudo pip install against it; create a virtual environment instead: python3 -m venv .venv && source .venv/bin/activate.

Newer versions

Ubuntu ships a specific Python 3 per release. For a newer interpreter, add the deadsnakes PPA or install pyenv, leaving the system version intact.