python install_error ai_generated true

pytest.PytestConfigError: Unknown plugin: 'pytest-cov'

ID: python/pytest-missing-plugin

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-07-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.11 active

Root Cause

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.

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Adding the plugin name to conftest.py's pytest_plugins list without installing it first still raises the same error.

  2. 50% fail

    Ignoring the error and running tests with -p no:plugin may suppress the error but disables the plugin's functionality.