我已经安装了 pytest 进行 python 测试,但是No such file or directory当我只是尝试从项目文件夹运行它时出现错误。
它位于应该可以通过PATH变量访问的位置,但是(尽我所能来描述问题)没有被“找到”。出于某种原因,当我输入“pytest”时,我的 shell 正在寻找错误的位置;如果我指定位置,那么 pytest 将运行良好。
往里看 /usr/bin
kirk@kirk:~/develop/foo$ pytest
bash: /usr/bin/pytest: No such file or directory
Run Code Online (Sandbox Code Playgroud)
它实际上在 中/usr/local/bin,它是路径的一部分,并且在我明确调用该位置时起作用。
kirk@kirk:~/develop/foo$ whereis pytest
pytest: /usr/local/bin/pytest
kirk@kirk:~/develop/foo$ echo $PATH
/home/kirk/bin:/home/kirk/.local/bin:/usr/local/sbin:/usr/local/bin:
/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
kirk@kirk:~/develop/foo$ /usr/local/bin/pytest
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/kirk/develop/foo, inifile: pytest.ini
collected 0 items
========================= no tests ran in 0.00 seconds =========================
Run Code Online (Sandbox Code Playgroud)
什么会导致这种行为?