# CoverageFailure: 无法导入模块 'my_module' 进行覆盖率测量

- **ID:** `python/pytest-cov-import-error`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pytest-cov 无法导入指定的模块，可能是因为它未安装或不在 Python 路径中。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Run `python -c "import my_module"` to verify the module is importable, then adjust PYTHONPATH if needed.
   ```
2. **** (85% 成功率)
   ```
   Specify the full package path: `pytest --cov=src/my_module` or use `--cov=my_package.my_module`
   ```

## 无效尝试

- **** — The module might already be installed in a different environment; the issue is often path-related rather than installation. (50% 失败率)
- **** — The module might be in a subpackage; coverage requires the full dotted path. (70% 失败率)
