ModuleNotFoundError: No module named 'hypothesis'
Fixes ModuleNotFoundError: No module named 'hypothesis' by installing the Hypothesis library. Use when property-based tests cannot import hypothesis at all. Not for strategy usage errors.
TL;DR
Run python -m pip install hypothesis. This error means the Hypothesis property-testing library is not installed in the environment running your tests.
ModuleNotFoundError: No module named 'hypothesis'Fix it
- Install it. Run
python -m pip install hypothesis.
- Expected:
Successfully installed hypothesis-....
- Verify. Run
python -c "import hypothesis; print(hypothesis.__version__)".
- Expected: a version number prints.
When this applies
- Tests use
@givenor hypothesis strategies but the env lacks the package. - Fresh CI image or new virtualenv.
When it does not apply
- If hypothesis imports but strategies fail, that is a usage error, not a missing install.
Tool compatibility
hypothesis 6.x, Python 3.8+. pip install hypothesis.
Why it happens
Hypothesis is a third-party package, not stdlib. It must be installed per environment.
Edge cases
- The
.hypothesisexample database directory is created automatically; you do not need to create it.
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.