How to fix How to fix 'HASH mismatch' error with pip in Python

PythonINTERMEDIATEMEDIUMUpdated Dec 7, 2025ยท 169 views

pip verified the downloaded package file and found it doesn't match the expected hash. This indicates corruption, tampering, or incorrect requirements specification.

Quick fix

Fixes How to fix 'HASH mismatch' error with pip

  1. Verify the root cause
  2. Apply the appropriate fix
  3. Retry the installation
python โ€” error
# How to fix 'HASH mismatch' error with pip

What this error means

When pip installs from a requirements file with --require-hashes, it verifies that each downloaded package matches the specified hash values. If the actual file hash doesn't match the expected hash, pip rejects the package to prevent installing corrupted or modified files.

Typical symptoms

  • pip install fails with 'HASH mismatch'
  • Error includes expected vs actual hash values
  • Works without --require-hashes flag
  • Downloaded file is corrupted
  • Network issue during download resulted in partial/bad file
  • Wrong hash value in requirements file
  • Specific package version fails hash check

Common causes

  1. Incorrect hash in requirements.txt
  2. Downloaded package file corrupted during transfer
  3. Network interruption during download
  4. Malicious man-in-the-middle modifying package
  5. Pip cache contains corrupted version of package
  6. PyPI or mirror serving incorrect package
  7. Hash algorithm mismatch (sha256 vs md5)

How to fix this error

1Verify the root cause

Review the error message above and identify which cause applies to your situation. Run additional diagnostics if needed.

2Apply the appropriate fix

Follow the corresponding solution from the causes section above.

3Retry the installation

Once you've addressed the root cause, try running 'pip install' again.

Frequently asked questions

What does "How to fix 'HASH mismatch' error with pip" mean?
When pip installs from a requirements file with --require-hashes, it verifies that each downloaded package matches the specified hash values. If the actual file hash doesn't match the expected hash, pip rejects the package to prevent installing corrupted or modified files.
How do I fix "How to fix 'HASH mismatch' error with pip"?
pip verified the downloaded package file and found it doesn't match the expected hash. This indicates corruption, tampering, or incorrect requirements specification.
What causes "How to fix 'HASH mismatch' error with pip"?
Incorrect hash in requirements.txt Downloaded package file corrupted during transfer Network interruption during download
Is the "How to fix 'HASH mismatch' error with pip" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading