Closed edmorley closed 1 week ago
This blocks Heroku upgrading from pip 24.0 to something newer (eg https://github.com/heroku/heroku-buildpack-python/pull/1619), since we will no doubt have a long tail of users with existing cached site-packages with packages using non-standard dependency specifiers installed. (Whilst users should be upgrading to newer versions of packages with those specifiers fixed, if there isn't a clear error message, they won't know what the issue is or how to resolve it.)
Note: This issue seems similar to #12945, though that issue seems more about initial installation, rather than "existing installation", plus doesn't have explicit steps to reproduce - so it seemed best to file a separate issue.
I've created #12953 that gives a much clearer error message:
$ python -m pip install --dry-run celery
Requirement already satisfied: celery in ./.venv/lib/python3.12/site-packages (4.4.7)
error: invalid-installed-package
× Cannot process installed package celery 4.4.7 in '/home/damian/opensource/contributions/pip/.venv/lib/python3.12/site-packages' because it has an invalid requirement:
│ Expected matching RIGHT_PARENTHESIS for LEFT_PARENTHESIS, after version specifier
│ pytz (>dev)
│ ~^
╰─> Starting with pip 24.1, packages with invalid requirements can not be processed.
hint: To proceed this package must be uninstalled using 'pip<24.1', some other Python package tool, or manually deleted.
Edit: Updated message to reflect latest version of PR
Description
In #12063 support for non-standard (ie: broken) dependency specifiers was first deprecated, and then in pip 24.1.0, removed entirely.
As such pip now ignores such broken packages when resolving dependencies during package installation - meaning they can no longer be installed. This is fine, and currently working as expected.
However, what it not working as expected, is that if there are any already-installed dependencies with those dependency specifiers then pip install fails with an internal error and does not explain what happened or how to resolve it.
Expected behavior
Using the steps to reproduce below, pip should either:
"celery"
is satisfied by any installed version. (And in fact the log output below even says "Requirement already satisfied".)pip version
24.2
Python version
3.12.5 (homebrew)
OS
macOS
How to Reproduce
mkdir testcase && cd $_
python -m venv .venv && source .venv/bin/activate
pip install pip==24.0
pip install celery==4.4.7
pip install pip==24.2
pip install celery
Output
Code of Conduct