# pytest 配置错误：未知插件：'pytest-cov'

- **ID:** `python/pytest-missing-plugin`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pytest 配置文件（pytest.ini、pyproject.toml 或 conftest.py）引用了当前 Python 环境中未安装的插件，导致 pytest 启动失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.11 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Install the missing plugin using pip: pip install pytest-cov, then re-run pytest.
   ```
2. **** (90% 成功率)
   ```
   If the plugin is not needed, remove its reference from the configuration file (e.g., delete 'pytest-cov' from addopts or plugins list).
   ```

## 无效尝试

- **** — Adding the plugin name to conftest.py's pytest_plugins list without installing it first still raises the same error. (80% 失败率)
- **** — Ignoring the error and running tests with -p no:plugin may suppress the error but disables the plugin's functionality. (50% 失败率)
