ImportError: cannot import name 'transfer_markers' when testing with pytest

  • A+
Category:Languages

When I run tests for my python project by running the following command:

python setup.py test (or) pytest project_name 

I get the following error:

.../project_name/.eggs/pytest_asyncio-0.9.0-py3.6.egg/pytest_asyncio/plugin.py", line 8, in <module> from _pytest.python import transfer_markers  ImportError: cannot import name 'transfer_markers' 

 


When I looked it up online, there was almost no mention of that particular error message anywhere. Something similar has happened to me a few times before where previously working code just breaks and it's usually because there's a new version of an important package.

I looked at the pytest release history, and it looks like pytest==4.1.0 has been released a few hours ago (as of this post).

The solution is to revert back to the last stable version of pytest i.e. pytest==4.0.2 by running the following command:

pip install pytest==4.0.2 

The tests are running now.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: