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

By 

Updated on

5 min read

Install Python pip on Debian 11, 12, and 13

When a Python package is not available through Debian’s repositories, pip can install it from the Python Package Index (PyPI) or another package index. On Debian 12 and 13, project packages should be installed inside a virtual environment to avoid conflicts with the system Python installation.

This tutorial explains how to install pip for Python 3 (pip3) on Debian 11, 12, and 13 using the apt package manager, create a virtual environment, and manage Python packages safely.

Quick Reference

For a printable quick reference, see the pip cheatsheet .

The package management commands below assume that you have activated a virtual environment. Debian 12 and 13 block pip from modifying the system Python environment by default.

CommandDescription
pip3 install packageInstall a package
pip3 install package==1.0.0Install a specific version
pip3 install --upgrade packageUpgrade an installed package
pip3 install -r requirements.txtInstall from a requirements file
pip3 uninstall packageRemove a package
pip3 listList all installed packages
pip3 show packageShow details about a package
pip3 freezeOutput 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.

Info
Python 2 reached end of life on January 1st, 2020. Python 2 packages are not available in Debian 11, 12, or 13 repositories.

Run the following commands to refresh the local package index and install pip, virtual environment support, and their dependencies:

Terminal
sudo apt update
sudo apt install python3-pip python3-venv

To ensure that pip has been installed correctly on your system, you can check its version by typing:

Terminal
pip3 --version

The version number may be different, but it will look something like the one below:

output
pip 25.1.1 from /usr/lib/python3/dist-packages/pip (python 3.13)

This output confirms that Debian installed pip for Python 3. The exact pip and Python versions depend on your Debian release. 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 11, 12, or 13, do it inside a virtual environment rather than in the system Python environment:

Terminal
python3 -m venv myenv
source myenv/bin/activate
pip3 install --upgrade pip

To get a list of all pip commands and options, type:

Terminal
pip3 --help

You can get more information about a specific command using pip3 <command> --help. For example, to get more information about the install command, type:

Terminal
pip3 install --help

Installing Packages with pip

Warning
Starting with Debian 12, the system Python environment is marked as externally managed (PEP 668). Running 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:

Terminal
python3 -m venv myenv
source myenv/bin/activate

Then install packages as usual:

Terminal
pip3 install package_name

To install a specific version of a package, append == and the version number after the package name. For example, the following command installs version 0.4.6 of Colorama:

Terminal
pip3 install colorama==0.4.6

Installing 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:

Terminal
pip3 install -r requirements.txt

Listing Installed Packages

To list all the installed pip packages, use the list subcommand:

Terminal
pip3 list

Upgrading a Package with pip

To upgrade an already installed package to the latest version, enter:

Terminal
pip3 install --upgrade package_name

Uninstalling Packages with pip

To uninstall a package, run:

Terminal
pip3 uninstall package_name

Troubleshooting

pip3: command not found
Refresh the package index and reinstall the python3-pip package:

Terminal
sudo apt update
sudo apt install python3-pip

The venv module is unavailable
If python3 -m venv myenv reports that ensurepip is unavailable, install Debian’s virtual environment package and retry:

Terminal
sudo apt install python3-venv
python3 -m venv myenv

externally-managed-environment error
Debian 12 and 13 prevent pip from changing the system Python environment. Create and activate a virtual environment, then install the package inside it:

Terminal
python3 -m venv myenv
source myenv/bin/activate
pip3 install package_name

Avoid using --break-system-packages for routine package installation because it can create conflicts with packages managed by apt.

FAQ

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.

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

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