V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
duzhonglin
V2EX  ›  pytest

pytest 安装到虚拟环境

  •  
  •   duzhonglin · 2019-04-12 11:11:47 +08:00 · 4017 次点击
    这是一个创建于 1812 天前的主题,其中的信息可能已经有所发展或是发生改变。
    python 代码调用 pytest 提示找不到 pytest 模块,删除虚拟环境后是正常的,不晓得是什么原因呢?
    2 条回复    2019-04-12 21:11:29 +08:00
    megachweng
        1
    megachweng  
       2019-04-12 12:21:48 +08:00 via iPhone
    好歹贴一下日志和代码呀
    duzhonglin
        2
    duzhonglin  
    OP
       2019-04-12 21:11:29 +08:00
    @megachweng 这是代码
    import pytest


    def test_main():
    assert 5!=5

    if __name__ == "__main__":
    pytest.main()

    下面是报错提示:
    [Running] python -u "d:\MyPytest\test_sample.py"
    Traceback (most recent call last):
    File "d:\MyPytest\test_sample.py", line 1, in <module>
    import pytest
    ModuleNotFoundError: No module named 'pytest'

    [Done] exited with code=1 in 0.185 seconds


    在命令行是可以正常执行得
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2717 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:30 · PVG 23:30 · LAX 08:30 · JFK 11:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.