在pytest虚拟环境中安装模块后,我使用python代码调用并运行提示找到pytest模块。
我在虚拟环境之外安装了 pytest 模块。我可以用python正常调用它。
import pytest
def test_main():
assert 5!=5
if __name__ == "__main__":
pytest.main()
Run Code Online (Sandbox Code Playgroud)
错误如下?
[运行] python -u "d:\MyPytest\test_sample.py" 回溯(最近一次调用):文件“d:\MyPytest\test_sample.py”,第 1 行,在 import pytest ModuleNotFoundError: No module named 'pytest' [完成] 在 0.185 秒内以代码 = 1 退出