ModuleNotFoundError: No module named 'attrs'
Fixes ModuleNotFoundError: No module named 'attrs' by installing hypothesis's missing dependency. Use when hypothesis's import chain breaks on attrs. Not for a missing hypothesis install.
TL;DR
Run python -m pip install attrs, or reinstall hypothesis with dependencies: python -m pip install --force-reinstall hypothesis. Hypothesis depends on attrs; skipping deps leaves it missing.
ModuleNotFoundError: No module named 'attrs'Fix it
- Install the missing dep. Run
python -m pip install attrs.
- Expected:
Successfully installed attrs-....
- Verify. Run
python -c "import hypothesis; print('ok')".
- Expected: prints
ok.
When this applies
- Importing hypothesis fails naming attrs.
- Minimal installs with
--no-deps.
When it does not apply
- If hypothesis itself is missing, install it first.
Tool compatibility
hypothesis 6.x requires attrs. Python 3.8+.
Why it happens
attrs is a hard dependency of hypothesis. Dependency-skipping installs break it.
Edge cases
- Note the package is
attrs(plural); the classic import isimport attrorimport attrs. Install the package name with pip.
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.