duzhonglin
V2EX  ›  pytest

pytest 安装到虚拟环境

  •  
  •   duzhonglin · Apr 12, 2019 · 5155 views
    This topic created in 2597 days ago, the information mentioned may be changed or developed.
    python 代码调用 pytest 提示找不到 pytest 模块,删除虚拟环境后是正常的,不晓得是什么原因呢?
    2 replies    2019-04-12 21:11:29 +08:00
    megachweng
        1
    megachweng  
       Apr 12, 2019 via iPhone
    好歹贴一下日志和代码呀
    duzhonglin
        2
    duzhonglin  
    OP
       Apr 12, 2019
    @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


    在命令行是可以正常执行得
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   915 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 131ms · UTC 21:12 · PVG 05:12 · LAX 14:12 · JFK 17:12
    ♥ Do have faith in what you're doing.