python install_error ai_generated true

pluggy.PluginValidationError: 无法加载插件 'pytest_cov': (pytest 8.2.0 (...), 要求 'pytest>=8.3') 错误: 插件已以不同名称注册

pluggy.PluginValidationError: Plugin 'pytest_cov' could not be loaded: (pytest 8.2.0 (...), requirement 'pytest>=8.3') ERROR: plugin already registered under a different name

ID: python/pytest-plugin-autoload-conflict

其他格式: JSON · Markdown 中文 · English
80%修复率
82%置信度
0证据数
2024-07-05首次发现

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

两个插件声明了相同的插件名,或某插件要求比已安装版本更新的 pytest。常见于混用 pytest-cov/pytest-xdist 版本,或本地 conftest 定义了名称冲突的 hookimpl。

English

Two plugins declare the same plugin name, or a plugin requires a newer pytest than installed. Common when mixing pytest-cov/pytest-xdist versions or when a local conftest defines a hookimpl with a conflicting name.

generic

解决方案

  1. 93% 成功率
    pip install -U "pytest>=8.3" pytest-cov pytest-xdist
    pip check
  2. 85% 成功率
    PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest -p pytest_cov -p pytest_xdist

无效尝试

常见但无效的做法:

  1. 70% 失败

    Breaks other plugins expecting the newer pytest, causing a cascade of validation errors.

  2. 60% 失败

    If the plugin is still auto-loaded via entry points, the conflict persists; you must also set PYTEST_DISABLE_PLUGIN_AUTOLOAD.