# ModuleNotFoundError: No module named 'myapp'
# when running pytest from repo root with src/ layout

- **ID:** `python/pytest-import-mismatch-src-layout`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

src/ layout requires the package to be installed or on sys.path; running pytest from the repo root without `pip install -e .` leaves src/myapp unreachable.

## Version Compatibility

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

## Workarounds

1. **** (98% success)
   ```
   pip install -e .
# or with build backend
pip install -e ".[test]"

# then
pytest
   ```
2. **** (92% success)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
pythonpath = ["src"]
testpaths = ["tests"]
   ```

## Dead Ends

- **** — Duplicated boilerplate and still fails for subprocess-based tests or coverage tools that re-import. (80% fail)
- **** — Abandons src/ layout benefits (isolation, editable install correctness) and may break packaging. (70% fail)
- **** — Not reproducible in CI; each developer must remember the env var. (85% fail)
