pytest默认使用的是main system packages,如果需要在虚拟环境中运行,需要运行: python -m pytest test.py 如果需要打印中间结果: pytest test.py -s