# ModuleNotFoundError: No module named 'myapp'

- **ID:** `python/pytest-import-mode-src-not-found`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pytest's default import mode (prepend) inserts test directories into sys.path, not the project root. A src/ layout package isn't importable from tests without installation or path configuration.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   pip install -e .
# or with pyproject.toml [build-system] set, uv pip install -e .
   ```
2. **** (90% success)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
pythonpath = ["src"]
addopts = "--import-mode=importlib"
   ```

## Dead Ends

- **** — Relative paths break depending on CWD; also pollutes sys.path and hides packaging issues. (70% fail)
- **** — Works locally but isn't reproducible in CI; pytest may still use prepend mode and shadow the path. (60% fail)
