Python:导入错误:没有名为 _pluggy 的模块

Pub*_*oda 6 python pytest python-2.7 pytest-cov

ImportError: No module named _pluggy使用 pytest 运行测试时出现错误。

然后我尝试使用pip install pluggy. 它安装pluggy==0.6.0成功,但仍然给出错误。

版本列表(来自运行pip freeze | grep pytest

  • pytest==3.3.1
  • pytest-cov==2.5.1
  • pytest-元数据==1.5.0
  • pytest-runner==3.0
  • 插头==0.6.0
  • 蟒蛇 2.7.12

下面显示的是堆栈跟踪

在 virtualenv 中运行时,测试成功运行。在非 virtualenv 环境中导致此错误的可能原因是什么?

Pub*_*oda 6

正如@bouteillebleu 指出的那样,问题出在 pytest-metadata 包中。

解决方案是升级包

pip install --upgrade pytest-metadata
Run Code Online (Sandbox Code Playgroud)