Updated: 8 October 2026 · Applies to: Debian 13 (Python 3.13.5, pip 25.1.1, pipx 1.7.1); also checked on Ubuntu 26.04 (Python 3.14, pip 25.1.1), Ubuntu 24.04 (Python 3.12.3, pip 24.0) and AlmaLinux 10.2
Install pip on Debian from the Debian repository:
sudo apt update sudo apt install python3-pip
That gives you the pip and pip3 commands. On Debian 12 and later, however, pip install into the system Python stops with error: externally-managed-environment. This is intended. Install packages into a virtual environment (for your own projects), with pipx (for command-line tools) or as a Debian package (apt install python3-<name>). All three are shown below.
Step 1: Install and check pip
- Install pip, plus the venv module you will need in the next step:
sudo apt update sudo apt install python3-pip python3-venv
- Check the version:
$ pip --version pip 25.1.1 from /usr/lib/python3/dist-packages/pip (python 3.13)
python3-pip also installs its recommended packages, including build-essential and python3-dev (compilers and headers needed for Python packages that contain C code). On a fresh Debian 13 system that was 80 new packages; with sudo apt install --no-install-recommends python3-pip it was 12. Skip the recommends only if you will not build packages from source.
Debian has no python command by default, only python3. If a script calls python, install python-is-python3.
Why pip install fails: error: externally-managed-environment
This is what you get on Debian 13, as root, as a normal user and with --user:
$ pip install requests
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.13/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Since Debian 12, the system Python is marked as managed by apt (PEP 668, through the file /usr/lib/python3.13/EXTERNALLY-MANAGED on Debian 13). Debian's own tools depend on the Python modules apt installed, and pip would otherwise overwrite them with other versions. So pip now refuses to touch the system Python and points you to the options below.
Option 1: A virtual environment (your projects and libraries)
- Create the environment as the user who will run the code (not as root):
python3 -m venv ~/myapp-venv
- Activate it.
pythonandpipnow point into the environment:$ source ~/myapp-venv/bin/activate $ which python pip /home/alice/myapp-venv/bin/python /home/alice/myapp-venv/bin/pip
- Install packages normally:
$ pip install requests ... Successfully installed certifi-2026.7.22 charset_normalizer-3.5.2 idna-3.20 requests-2.34.2 urllib3-2.8.0
- Leave the environment with
deactivate.
Useful extras:
- In cron jobs and systemd units, skip activation and call the environment's interpreter directly:
/home/alice/myapp-venv/bin/python /home/alice/myapp/run.py pip install --upgrade pipinside the environment upgrades only that copy (it went to pip 26.2.1 in our test, while the system pip stayed at 25.1.1).- Save and reuse the package list:
pip freeze > requirements.txt, thenpip install -r requirements.txtin a new environment.
If python3-venv is missing, creating the environment fails like this:
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.13-venv
Run sudo apt install python3-venv (it pulls in python3.13-venv) and repeat the python3 -m venv command; it worked over the half-created folder in our test. More on environments: How to create and activate a Python virtual environment.
Option 2: pipx (command-line tools from PyPI)
pipx gives every tool its own hidden environment and puts the command in ~/.local/bin. Debian's release notes recommend it for Python applications that are not packaged in Debian.
$ sudo apt install pipx
$ pipx install httpie
...
installed package httpie 3.2.4, installed using Python 3.13.5
These apps are now globally available
- http
- httpie
- https
$ pipx ensurepath
pipx ensurepath adds ~/.local/bin to your PATH; open a new shell or log in again to use it. Manage tools with pipx list, pipx upgrade httpie and pipx uninstall httpie.
Option 3: The Debian package
Many libraries are packaged as python3-<name>. They install system-wide, work with the system python3 and receive Debian security updates:
$ sudo apt install python3-requests $ python3 -c 'import requests; print(requests.__version__)' 2.32.3
The Debian version is usually older than PyPI (2.32.3 here against 2.34.2 from pip). If you need the newest release, use a virtual environment instead. Find packages with apt search python3-<name>.
What about --break-system-packages?
The flag does what it says: pip install --break-system-packages six installed the package on Debian 13, with pip warning that running as root "can result in broken permissions and conflicting behaviour with the system package manager". Use it only in throwaway containers. On a server, a later pip upgrade of a module apt depends on can break system tools, and do not delete the EXTERNALLY-MANAGED file either.
Ubuntu, AlmaLinux and Rocky Linux
- Ubuntu 26.04 and 24.04 behave the same way: the same
apt install python3-pipcommand, the same externally-managed-environment error and the same three fixes. Ubuntu 26.04 ships pip 25.1.1 with Python 3.14; Ubuntu 24.04 ships pip 24.0 with Python 3.12.3. - AlmaLinux and Rocky Linux: install with
sudo dnf install python3-pip(pip 23.3.2 with Python 3.12 on AlmaLinux 10.2). There is noEXTERNALLY-MANAGEDfile, so pip does not stop you, but a virtual environment is still the safe choice for the same reasons.
To move to a newer Python or pip without damaging the system copy, see How to update Python and pip on Linux without breaking your system.
Common errors
- pip: command not found:
python3-pipis not installed, or (inside a project) the virtual environment is not activated. - python: command not found: use
python3, or installpython-is-python3. - error: externally-managed-environment: use a virtual environment, pipx or the
python3-package, as above. - ensurepip is not available: install
python3-venv.
Official documentation: Python in Debian (Debian Wiki), venv (Python documentation).
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
