Working with PEP 668 in Debian 12

Published: 9 Mar 2023 Last updated: 26 May 2023

Table Of Contents

Introduction

Recent decisions have changed the way Python package installations are handled in Debian 12. When trying to install a package into the default environment with pip, you will see an error notice like this:

A terminal with "pip3 install pdm" entered. The command shows an error message in response, detailing the error caused by implementation of PEP-668

Although at first glance this seems complex, the solution is relatively simple.

Determining manually installed packages

The first step is to determine which Python packages on the system have been installed manually through pip via the --user flag. We can do this by listing them. Make sure you're not currently in a virtual environment, then run the following command:

$ pip3 list --user

Now look through the list and make a note of any that you've installed yourself.

Installing pipx

The next step is to install pipx. This should be done with apt (or your chosen OS package manager) so that the distro's supported version of the tool is used:

$ sudo apt install pipx

Installing packages

Now we can install our packages. For each manually installed package in the list, run the following command:

$ pipx install --force <package>

The --force parameter is required in order to override symlinks which were created previously and which will prevent access to newly installed versions if not altered. For any other packages you choose to install later, that were not previously installed with pip, --force is not required.

Updating installed packages and setting up shell auto-completion

Updating packages installed via pipx is easy with the following command:

$ pipx upgrade-all

To enable shell auto-completion, run this command and follow the instructions:

$ pipx completions

Sources

I hope you enjoyed reading this article and found it informative. If you have any comments or suggestions, feel free to get in touch! :) Back to Top