首页 > 解决方案 > pytest 错误:ImportError: cannot import name 'Expression' from '_pytest.mark'

问题描述

我收到此错误:

conftest.py:95: in <module>
    from framework.scheduler import PytestScheduler
framework/scheduler.py:33: in <module>
    from _pytest.mark import Expression, MarkMatcher
E   ImportError: cannot import name 'Expression' from '_pytest.mark' (/usr/lib/python3/dist-packages/_pytest/mark/__init__.py)

它可能是我的 pytest 版本吗?我怎么知道我应该使用哪个版本?

该文件/usr/lib/python3/dist-packages/_pytest/mark/__init__.py存在,因此已安装。

标签: pythonpython-3.xpytest

解决方案


sudo pip install --upgrade attrs==21.2.0
sudo pip install --upgrade pytest==6.2.4

为我固定


推荐阅读