python
install_error
ai_generated
true
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Expected sha256 3f7a... Got a91c...
ID: python/pip-hash-mismatch-downloaded-wheel
80%Fix Rate
88%Confidence
0Evidence
2024-07-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| pip>=21.0 | active | — | — | — |
Root Cause
A `--hash` pin in requirements.txt does not match the hash of the downloaded artifact. Causes: package was re-uploaded, hash was computed on a different wheel (platform tag), or the artifact was tampered with.
generic中文
requirements.txt 中的 `--hash` 固定值与下载产物的哈希不匹配。原因:包被重新上传、哈希基于不同 wheel(平台标签)计算,或产物被篡改。
Workarounds
-
90% success
Regenerate hashes for the exact artifacts you intend to install: pip download --no-deps --dest /tmp/wheels <pkg>==<ver> pip hash /tmp/wheels/<pkg>-<ver>-*.whl Update requirements.txt with the new sha256.
-
85% success
Use pip-tools to keep hashes in sync automatically: pip install pip-tools pip-compile --generate-hashes requirements.in pip-sync requirements.txt
Dead Ends
Common approaches that don't work:
-
90% fail
pip still enforces --hash pins; --no-deps and --ignore-installed do not bypass hash verification.
-
40% fail
Removes supply-chain protection and defeats the purpose of the pinned hash; acceptable only as a temporary local debug step.