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:
Although at first glance this seems complex, the solution is relatively simple.
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.
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
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 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