How to Install 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.
| 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, virtual environment support, and their dependencies:
sudo apt update
sudo apt install python3-pip python3-venvTo 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 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:
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. For example, the following command installs version 0.4.6 of Colorama:
pip3 install colorama==0.4.6Installing 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_nameTroubleshooting
pip3: command not found
Refresh the package index and reinstall the python3-pip package:
sudo apt update
sudo apt install python3-pipThe venv module is unavailable
If python3 -m venv myenv reports that ensurepip is unavailable, install Debian’s virtual environment package and retry:
sudo apt install python3-venv
python3 -m venv myenvexternally-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:
python3 -m venv myenv
source myenv/bin/activate
pip3 install package_nameAvoid 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 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