# 错误：这些包与需求文件中的哈希值不匹配。如果您更新了包版本，请更新哈希值。

- **ID:** `python/pip-hash-mismatch-requirements`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

下载产物的 SHA256 与 requirements.txt 中固定的 --hash 值不匹配，表明哈希过期或产物被篡改/替换。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   pip-compile --generate-hashes requirements.in
   ```
2. **** (90% 成功率)
   ```
   pip download pkg==1.2.3 -d /tmp/dl
python -c "import hashlib,sys;print(hashlib.sha256(open(sys.argv[1],'rb').read()).hexdigest())" /tmp/dl/*.whl
   ```

## 无效尝试

- **** — --no-deps does not disable hash verification; pip still validates hashes. (90% 失败率)
- **** — Removing hashes defeats the purpose and may violate policy; also breaks reproducible installs. (60% 失败率)
- **** — Trusted-host only affects TLS verification, not artifact hash verification. (85% 失败率)
