# ERROR collecting mypkg/mod.py
E   ImportError: cannot import name 'helper' from 'mypkg.mod' (unknown location)

- **ID:** `python/pytest-doctest-import-failure`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pytest --doctest-modules tries to import every module, including ones with side effects or circular imports, causing collection-time import errors.

## Version Compatibility

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

## Workarounds

1. **** (85% success)
   ```
   Fix the circular import by moving the import inside the function, or use `--doctest-modules` with `--import-mode=importlib`.
   ```
2. **** (80% success)
   ```
   Exclude problematic modules explicitly:
[tool.pytest.ini_options]
addopts = "--doctest-modules --ignore=mypkg/cli.py"
   ```

## Dead Ends

- **** — Skips doctests for that module entirely, losing coverage. (55% fail)
- **** — The module still can't be imported due to the underlying circular import or missing dependency. (60% fail)
