ERROR
pip
data_error
ai_generated
true
ERROR: The line in requirements.txt has an invalid hash format: 'sha256:abc123...' The hash must be in the format 'sha256:...' (no spaces, lowercase).
ID: pip/requirements-hash-invalid-line
95%Fix Rate
88%Confidence
1Evidence
2024-02-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| pip 23.3 | active | — | — | — |
| pip 24.0 | active | — | — | — |
| pip 24.1 | active | — | — | — |
Root Cause
A hash value in a requirements.txt file is malformed, e.g., contains uppercase letters, spaces, or incorrect algorithm prefix, causing pip to reject the entire line during hash verification.
generic中文
requirements.txt 文件中的哈希值格式错误,例如包含大写字母、空格或错误的算法前缀,导致 pip 在哈希验证期间拒绝整行。
Official Documentation
https://pip.pypa.io/en/stable/topics/secure-installs/#hash-checking-modeWorkarounds
-
95% success Regenerate the hash using pip's built-in tool: pip hash /path/to/package.whl
Regenerate the hash using pip's built-in tool: pip hash /path/to/package.whl
-
90% success Manually correct the hash format in requirements.txt to lowercase and colon-separated: sha256:abcdef1234567890...
Manually correct the hash format in requirements.txt to lowercase and colon-separated: sha256:abcdef1234567890...
-
85% success Use a hash generation script: python -c "import hashlib; print('sha256:' + hashlib.sha256(open('package.whl','rb').read()).hexdigest())"
Use a hash generation script: python -c "import hashlib; print('sha256:' + hashlib.sha256(open('package.whl','rb').read()).hexdigest())"
中文步骤
使用 pip 内置工具重新生成哈希:pip hash /path/to/package.whl
手动修正 requirements.txt 中的哈希格式为小写并用冒号分隔:sha256:abcdef1234567890...
使用哈希生成脚本:python -c "import hashlib; print('sha256:' + hashlib.sha256(open('package.whl','rb').read()).hexdigest())"
Dead Ends
Common approaches that don't work:
-
50% fail
Pip strictly parses the hash format; any deviation from 'algorithm:hexdigest' causes rejection.
-
80% fail
Without the algorithm prefix, pip cannot determine which hash function to use for verification.