pip: "Requirement already satisfied" reported for package conflicts

Package names do not have to correspond to the name of the top-level module contained in the package. For example the pyxdg package installs the xdg module, which is a known problem since there also is an xdg package that installs the same-named xdg module.

Pip unfortunately handles such conflicts very poorly. In the case the pyxdg module already is installed, the following can be observed:

$ pip install xdg                           
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: xdg in /usr/lib/python3/dist-packages (5)

“Requirement already satisfied” here is just wrong … the package that would get installed by pip install xdg is a different package than the one already present in /usr/lib/python3/dist-packages (which is pyxdg).

Expected behavior

I would expect pip to report an error message like:

error: package conflict: there already exists a same-named package in /usr/lib/python3/dist-packages

pip version

22.3.1

Python version

Python 3.9.2

OS

Debian

How to Reproduce

  1. apt install python3-xdg
  2. pip install xdg

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

It’s just as much a bug with Debian as it is with pip. So given that you felt it was worth reporting here, you should report it there. Even if just to tell them that their packaging is misleading for users, causing them to incorrectly assume that pip isn’t working correctly 🙂

The xdg-5.egg-info file is what tells pip that the xdg distribution is installed. It appears to be correct, and it contains Name: xdg, so it’s understandable that pip believes that is installed.

Someone in Debian has seemingly tried to resolve the name conflict by grafting the (PyPI) xdg API onto the pyxdg module, and therefore deliberately claiming to pip that the Debian python3-xdg package contains both:

https://salsa.debian.org/python-team/packages/pyxdg/-/commit/2e61e056826ea13e6a1a49202a33213f6ee38219