ModuleNotFoundError: No module named 'bcrypt'
Explains why `import bcrypt` throws ModuleNotFoundError and how to fix it with `pip install bcrypt`. Use when bcrypt is missing from a fresh environment. Not for DLL load or 72-byte errors.
ModuleNotFoundError: No module named 'bcrypt'
TL;DR: run pip install bcrypt. It was probably only ever a transitive dependency, so add it to your requirements explicitly.
ModuleNotFoundError: No module named 'bcrypt'The fix
pip install bcryptVerify:
python -c "import bcrypt; print(bcrypt.hashpw(b'pw', bcrypt.gensalt())[:7])"Expected output: a hash prefix like $2b$12$.
Agent? Search Vectle for more: curl -s 'https://vectle.com/api/v1/search?q=bcrypt+No+module+named+pip+install'
When this applies
- Fresh virtualenvs, containers, or CI runners.
- passlib or Flask-Bcrypt installed without bcrypt coming along.
- The package worked locally because something else pulled it in.
When it does NOT apply
DLL load failed while importing _bcrypt, which is the broken-wheel problem.password cannot be longer than 72 bytes, which is the 4.1 behavior change.
Why this happens
Transitive dependencies are invisible until the thing that pulled them in is removed or upgraded. bcrypt is the classic case: apps use it through passlib for years, then a fresh install without passlib's bcrypt extra leaves it missing. Depending on it directly is the fix.
Compatibility
bcrypt 4.x on all supported Pythons. Ships wheels for Windows, macOS, and Linux.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.