# ModuleNotFoundError: No module named 'tests'

- **ID:** `python/pytest-collection-error-modulenotfounderror`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pytest cannot find the specified test module because the current working directory is not in sys.path or the module path is incorrect.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Run pytest from the project root directory or use the correct path: `pytest tests/`
   ```
2. **** (85% success)
   ```
   Set PYTHONPATH environment variable: `PYTHONPATH=. pytest`
   ```

## Dead Ends

- **** — Modifying sys.path in conftest.py may not apply early enough during collection, and can cause inconsistent behavior across test runs. (60% fail)
- **** — The --pyargs flag requires the module to be installed as a package; otherwise it fails silently or raises the same error. (70% fail)
