Pip doesn't check for import package name conflicts (but could it in principle anyway?)

This thread is motivated by a new Stack Overflow question:

Putting aside the usefulness of having both of these packages in the same project, there seems to be a problem here: two different distribution packages want to use the same import package name. In a test venv I was able to confirm that Pip happily installs both packages… with the contents for both going to the same lib/python3.x/site-packages/magic folder inside the venv folder.

This doesn’t seem ideal. I assume it’s by design, and required by how the plugin/optional component, namespace package etc. systems work. But in this case, the two packages are not meant to combine, and in particular the first one’s __init__.py will get overwritten with the other. It’s not hard to imagine worse conflicts. I don’t know what exactly, but I feel like there should be some form of mitigation for this.

See thread on pip’s tracker for previous requests, discussions, and some of the difficulties changing this behaviour.

1 Like