6
votes

I am getting ImportError: No module named _pluggy error when running tests using pytest.

Then I tried installing pluggy using pip install pluggy. It installs pluggy==0.6.0 successfully, but is still giving the error.

Versions List (From running pip freeze | grep pytest)

  • pytest==3.3.1
  • pytest-cov==2.5.1
  • pytest-metadata==1.5.0
  • pytest-runner==3.0
  • pluggy==0.6.0
  • Python 2.7.12

Shown below is the stack trace

Tests run successfully when run in a virtualenv. What are the possible causes which can cause this error in a non-virtualenv environment?

1
github.com/pytest-dev/pytest/issues/2960 mentions that particular error - is that any help? - bouteillebleu
@bouteillebleu Awesome. Upgrading pytest-metadata solved the issue. Thanks - Pubudu Dodangoda
Excellent, glad it fixed the problem! - bouteillebleu

1 Answers

6
votes

As it was pointed out by @bouteillebleu the issue was in pytest-metadata package.

The solution was to upgrade the package

pip install --upgrade pytest-metadata