# ModuleNotFoundError: No module named 'myapp'
  File "/app/tests/test_api.py", line 3, in <module>
    from myapp.api import create_app

- **ID:** `python/pytest-import-mode-sys-path`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The project root is not on sys.path when pytest runs. This happens when tests are invoked from a directory other than the project root, or when the package is not installed (pip install -e .) and there is no conftest.py at the project root to anchor rootdir.

## Version Compatibility

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

## Workarounds

1. **** (97% success)
   ```
   pip install -e .
pytest tests/
   ```
2. **** (90% success)
   ```
   # project/conftest.py (empty is enough)
touch conftest.py
pytest tests/
   ```
3. **** (93% success)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
pythonpath = ["."]
   ```

## Dead Ends

- **** — Depends on CWD at runtime; breaks in CI when pytest is invoked from a different directory, and pollutes each test file. (80% fail)
- **** — Works interactively but not in CI or IDE test runners; teammates hit the same error. (75% fail)
