You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--require-hashes does not correctly handle pinned package with extras #9644
Install this requirements.txt file with pip 21.0.1 or master in a new virtual environment.
A package is pinned to a non-latest version with an extra (here, requirements[security]) and another dependency requires this package without specifying the extra.
Output
Install fails with:
...
Collecting requests[security]==2.24.0
Using cached requests-2.24.0-py2.py3-none-any.whl (61 kB)
Collecting six==1.15.0
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting urllib3==1.25.11
Using cached urllib3-1.25.11-py2.py3-none-any.whl (127 kB)
Collecting requests<3
ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
requests<3 from https://files.pythonhosted.org/packages/29/c1/24814557f1d22c56d50280771a17307e6bf87b70727d975fd6b2ce6b014a/requests-2.25.1-py2.py3-none-any.whl#sha256=c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e (from requests-extra==1.0.0b3->-r requirements.txt (line 116))
The resolver does not recognise that requests[security]==2.24.0 fulfils requests<3, and tries to collect latest requests. This fails as it is has no pinned hash.
Additional information
Installation succeeds with --use-deprecated=legacy-resolver.
If the requirements file has no hashes, installation succeeds with the new resolver: Collecting requests<3 resolves to latest requests (2.25.1) in the install output, but the pinned version (2.24.0) is what ends up installed.
If all packages are already installed in the environment, pip install succeeds (with Requirement already satisfied) even with the new resolver.
Reacted by Marwan Aljubeh, John Whitlock, Jungkook Park, Calum Lind, Dustin Ingram, Michael K., Jonathon Belotti, Marcus Windmark, ukmukfukk, Malte Swart and 36 more
One workaround for this is to use --no-deps, which is a good idea by itself anyway (See the second warning here).
Reacted by Tony Bajan, Theron Luhn, Marcus Windmark, Lukas Anzinger, Márcio Carôso, Andy Freeland, ussserrr, Chris Cummings, Asbjørn Apeland, nandgator and 10 more
Edit: I thought I had posted this as off-topic but after looking at the requirements.txt generated by pip-tools I see that it is specifying extras: pyjwt[crypto]
Thanks @uranusjr. This is currently blocking CI and deployment for pypa/warehouse, is there any workaround? If not, could you explain at a high level what I'd need to do to fix this issue in pip?
I believe it’s possible to work around this by manually “unpacking” extras, e.g. add a line to also provide hashes to requests in addition to requests[security] (using the example provided by OP).
That still passes, but after looking more closely I was able to figure out what will cause it to fail:
two parent dependencies
one with a dependency on a child with an extra
one with a dependency on a child without an extra
a newer version of the child dependency available than is pinned
It seems like what's happening is that pip is not considering the child dependency with the extra to be equivalent to the child dependency without the extra, and attempting to install the latest version of the child dependency, and not using the existing pinned/hashed requirement when doing this, which causes the hash checking to fail.
I made a draft PR with the failing test here: #9995, but I don't have time at the moment to continue working on it to fix the issue.
Reacted by Tony Bajan, Calum Lind, Brian Skinn, Marwan Aljubeh, Mehmet and Adam Johnson
@cas-- It may be preferable to update all the dependencies that the extra includes to the latest versions instead. By removing the extra you are possibly removing sub-dependencies your application (or a dependency of your application) needs.
And then running the following fails with the below error.
> pip install -r requirements.txt
ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
googleapis-common-protos<2.0.dev0,>=1.56.2 from https://files.pythonhosted.org/packages/b7/14/3f8b5670e7e082a3735dc9a6411b4ba37af7e6662441ee66782906265632/googleapis_common_protos-1.64.0-py2.py3-none-any.whl#sha256=d1bfc569f70ed2e96ccf06ead265c2cf42b5abfc817cda392e3835f3b67b5c59 (from google-api-core[grpc]==2.19.1->-r requirements.txt (line 672))
Interestingly I'm not able to reproduce this on my M1 Mac laptop, but is consistently occuring in our CI which uses a Linux python3.10 docker image. Also can reproduce locally inside the docker image.
There are many users subscribed to this issue so making a comment makes a lot of noise.
Please no further requests for updates where there is clearly no status change, you can read if there are updates either here or if there is a newly linked PR in the future.
Pip continues to only be supported by volunteers, so it is up to someone to spend their spare time on writing up a well thought out design that can be agreed upon or a high quality PR that can be reviewed.
Useful posts here would be:
Novel use cases that have not been discussed before
A design proposal to fix
A helpful workaround that has not been discussed before
Please thumbs up the original post to express that you would like this fixed / implemented. I am marking the last few posts as off topic to help a little. If there are repeated further posts asking for an update this thread may be locked to maintainers only (only as last resort).
Reacted by Mihai Maruseac, Éric and Somya Ranjan Jena
Activity
maljub01 commentedon Mar 1, 2021
One workaround for this is to use
--no-deps, which is a good idea by itself anyway (See the second warning here).cas-- commentedon Apr 5, 2021
I think this might be the same issue I have encountered with pinned and hash-checking
botframework-connectorrequirements:Broken requirements file: requirements.txt
Steps to reproduce:
Actual result:
Workaround
Either install
pip <= 20.3.1, use tonybajan--use-deprecated=legacy-resolveroption or use maljub01--no-depsoption:Edit: I thought I had posted this as off-topic but after looking at the requirements.txt generated by pip-tools I see that it is specifying extras:
pyjwt[crypto]di commentedon Apr 24, 2021
If I understand correctly, #9775 did not fix this, but made it possible to fix this?
uranusjr commentedon Apr 24, 2021
More accurately, the basis of #9775 (#9771) makes it possible to fix this.
di commentedon Apr 25, 2021
Thanks @uranusjr. This is currently blocking CI and deployment for pypa/warehouse, is there any workaround? If not, could you explain at a high level what I'd need to do to fix this issue in pip?
uranusjr commentedon Apr 25, 2021
I believe it’s possible to work around this by manually “unpacking” extras, e.g. add a line to also provide hashes to
requestsin addition torequests[security](using the example provided by OP).di commentedon May 18, 2021
I tried to create a failing test for this:
but it's passing on the current main branch at e6414d6.
Is it possible that this has already been fixed, or is my test not properly exercising this bug?
uranusjr commentedon May 18, 2021
I think the failure case should be like this:
and change
parentto depend onchild[extra].di commentedon May 18, 2021
That still passes, but after looking more closely I was able to figure out what will cause it to fail:
It seems like what's happening is that
pipis not considering the child dependency with the extra to be equivalent to the child dependency without the extra, and attempting to install the latest version of the child dependency, and not using the existing pinned/hashed requirement when doing this, which causes the hash checking to fail.I made a draft PR with the failing test here: #9995, but I don't have time at the moment to continue working on it to fix the issue.
cas-- commentedon May 18, 2021
@di I have confirmed your theory by specifying another dependency without the extras package and everything installs
pyjwt[crypto]==1.5.3 \ --hash=sha256:500be75b17a63f70072416843dc80c8821109030be824f4d14758f114978bae7 \ --hash=sha256:a4e5f1441e3ca7b382fd0c0b416777ced1f97c64ef0c33bfa39daf38505cfd2f +pyjwt==1.5.3 \ + --hash=sha256:500be75b17a63f70072416843dc80c8821109030be824f4d14758f114978bae7 \ + --hash=sha256:a4e5f1441e3ca7b382fd0c0b416777ced1f97c64ef0c33bfa39daf38505cfd2fdi commentedon May 18, 2021
@cas-- It may be preferable to update all the dependencies that the extra includes to the latest versions instead. By removing the extra you are possibly removing sub-dependencies your application (or a dependency of your application) needs.
Add sidestep for pypa/pip#9644
90 remaining items
anentropic commentedon Oct 20, 2023
merwok commentedon Oct 20, 2023
Update local venv creation to avoid a bug in pip (#399)
devashish2203 commentedon Aug 27, 2024
We started running into this issue yesterday and as far as I know we haven't updated the requirements.txt in over a month.
The requirements.txt was created with the following command
And then running the following fails with the below error.
Interestingly I'm not able to reproduce this on my M1 Mac laptop, but is consistently occuring in our CI which uses a Linux python3.10 docker image. Also can reproduce locally inside the docker image.
tools/nwb-read-tests/Dockerfile: Don't install additional dependencies
jenstroeger commentedon Jun 5, 2025
ichard26 commentedon Jul 6, 2025
learnwithsomya commentedon Aug 11, 2025
notatallshaw commentedon Aug 11, 2025
There are many users subscribed to this issue so making a comment makes a lot of noise.
Please no further requests for updates where there is clearly no status change, you can read if there are updates either here or if there is a newly linked PR in the future.
Pip continues to only be supported by volunteers, so it is up to someone to spend their spare time on writing up a well thought out design that can be agreed upon or a high quality PR that can be reviewed.
Useful posts here would be:
Please thumbs up the original post to express that you would like this fixed / implemented. I am marking the last few posts as off topic to help a little. If there are repeated further posts asking for an update this thread may be locked to maintainers only (only as last resort).
pradyunsg commentedon Apr 5, 2026
I attempted to reproduce this on current main (8c5468d) with Python 3.13 and was unable to.
Reproduction attempt using the original scenario:
pip-compileproducesrequests[security]==2.24.0with hashes.requests-extradepends on bare requests<3.pipcorrectly resolves this torequests==2.24.0from therequests[security]==2.24.0pin — no hash error.We also have a test covering this pattern (added in #9995), which passes.
If anyone is still hitting this on a recent pip version, please share a minimal reproducer so we can investigate further.
pradyunsg commentedon Apr 6, 2026
#12095 should have fixed this, 2.5 years ago, if I did this bisect correctly.
pradyunsg commentedon Apr 6, 2026
Closing this out for now -- let us know if you've managed to get this error with pip 24 or newer.