python
install_error
ai_generated
true
pytest 配置错误:未知插件:'pytest-cov'
pytest.PytestConfigError: Unknown plugin: 'pytest-cov'
ID: python/pytest-missing-plugin
80%修复率
87%置信度
0证据数
2024-07-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.11 | active | — | — | — |
根因分析
pytest 配置文件(pytest.ini、pyproject.toml 或 conftest.py)引用了当前 Python 环境中未安装的插件,导致 pytest 启动失败。
English
The pytest configuration (pytest.ini, pyproject.toml, or conftest.py) references a plugin that is not installed in the current Python environment, causing pytest to fail on startup.
解决方案
-
95% 成功率
Install the missing plugin using pip: pip install pytest-cov, then re-run pytest.
-
90% 成功率
If the plugin is not needed, remove its reference from the configuration file (e.g., delete 'pytest-cov' from addopts or plugins list).
无效尝试
常见但无效的做法:
-
80% 失败
Adding the plugin name to conftest.py's pytest_plugins list without installing it first still raises the same error.
-
50% 失败
Ignoring the error and running tests with -p no:plugin may suppress the error but disables the plugin's functionality.