How to Install pip on Debian 11, 12, and 13

Pip is a tool for installing Python packages. With pip, you can search, download, and install packages from the Python Package Index (PyPI) and other package indexes.
This tutorial explains how to install pip for Python 3 (pip3) on Debian 11, 12, and 13 using the apt
package manager.
We will also show you how to install and manage Python packages with pip.
Quick Reference
For a printable quick reference, see the Python cheatsheet .
| Command | Description |
|---|---|
pip3 install package | Install a package |
pip3 install package==1.0.0 | Install a specific version |
pip3 install --upgrade package | Upgrade an installed package |
pip3 install -r requirements.txt | Install from a requirements file |
pip3 uninstall package | Remove a package |
pip3 list | List all installed packages |
pip3 show package | Show details about a package |
pip3 freeze | Output installed packages in requirements format |
Installing pip on Debian
Pip for Python 3 is included in the default Debian repositories, and the installation is pretty straightforward.
Run the following commands to refresh the local package index and install pip and all of its dependencies:
sudo apt update
sudo apt install python3-pipTo ensure that pip has been installed correctly on your system, you can check its version by typing:
pip3 --versionThe version number may be different, but it will look something like the one below:
pip 23.0.1 from /usr/lib/python3/dist-packages/pip (python 3.11)When a new version is released, you can update the python3-pip package through the command line or your desktop Software Update tool.
Using pip
With pip, you can install packages from PyPI and other sources, manage package versions, update packages, remove packages and more.
Python modules can be installed globally (accessible for all projects and users) or on a project basis.
If you want to install a Python module globally, you should prefer to install it as a package using the apt manager. Use pip to install Python modules globally only if no package is available.
Pip is mostly used inside a virtual environment. A Python virtual environment allows you to install Python modules in an isolated location for a specific project rather than being installed globally. This prevents issues caused by shared dependencies and libraries.
If you want to upgrade pip itself on Debian 12 or 13, do it inside a virtual environment rather than in the system Python environment:
python3 -m venv myenv
source myenv/bin/activate
pip3 install --upgrade pipTo get a list of all pip commands and options, type:
pip3 --helpYou can get more information about a specific command using pip3 <command> --help. For example, to get more information about the install command, type:
pip3 install --helpInstalling Packages with pip
pip3 install package directly will fail with an externally-managed-environment error. The recommended approach is to use a virtual environment
for installing packages.To install packages with pip, first create and activate a virtual environment:
python3 -m venv myenv
source myenv/bin/activateThen install packages as usual:
pip3 install package_nameTo install a specific version of a package, append == and the version number after the package name:
pip3 install tensorflow==2.13.0Installing Packages Using a Requirements File
requirements.txt is a text file containing a list of pip packages and their versions required to run a specific Python project.
To install a list of requirements specified in a file, use the following command:
pip3 install -r requirements.txtListing Installed Packages
To list all the installed pip packages, use the list subcommand:
pip3 listUpgrading a Package with pip
To upgrade an already installed package to the latest version, enter:
pip3 install --upgrade package_nameUninstalling Packages with pip
To uninstall a package, run:
pip3 uninstall package_nameFAQ
Does the installation differ between Debian 11, 12, and 13?
The apt install python3-pip command works the same on all three versions. The main difference is that Debian 12 and 13 enforce PEP 668, which prevents pip from installing packages directly into the system Python environment. Use a virtual environment instead.
What is the externally-managed-environment error?
This error appears on Debian 12 and 13 when you run pip3 install outside a virtual environment. It protects the system Python from conflicting packages. Create a virtual environment with python3 -m venv myenv and activate it before installing packages.
How do I use pip inside a virtual environment?
Run python3 -m venv myenv to create the environment, then source myenv/bin/activate to activate it. Once active, pip3 install package installs packages only within that environment. See the Python virtual environments guide
for more detail.
How do I save installed packages to a requirements file?
Run pip3 freeze > requirements.txt to write all currently installed packages and their versions to a file. You can then reproduce the environment on another system with pip3 install -r requirements.txt.
Conclusion
We have shown you how to install pip on Debian 11, 12, and 13 and how to manage Python packages using pip. For more information about pip, visit the pip user guide page.
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page