在虚拟环境中安装pytest
模块后,我使用Python代码调用并运行提示符以找到pytest
模块。
我在虚拟环境之外安装了pytest模块。 我可以正常使用Python调用它。
import pytest
def test_main():
assert 5!=5
if __name__ == "__main__":
pytest.main()
错误如下:
[运行] python -u "d:\MyPytest\test_sample.py" Traceback (most recent call last): File "d:\MyPytest\test_sample.py", line 1, in import pytest ModuleNotFoundError: 没有名为 'pytest' 的模块 [完成] 在 0.185 秒内以代码 1 退出