Installed pytest but running pytest in bash returns not found

[root@izbp1jfqk9lif6vh3vclhkz site-packages]# pytest
-bash: pytest: command not found

Try python -m pytest

Installing pytest via pip will not make it a system command, but will install it to python. The -m command runs pytest as its own command, and then any subsequent scripts will take as parameters.

[root@izbp1jfqk9lif6vh3vclhkz test]# python -m pytest test_01.py
======================================================================== test session starts ========================================================================
platform linux -- Python 3.7.4, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /root/test
plugins: allure-pytest-2.8.19
collected 2 items

test_01.py ..                                                                                                                                                 [100%]

========================================================================= 2 passed in 0.05s =========================================================================
[root@izbp1jfqk9lif6vh3vclhkz test]#

Finished, clock in and get off work

Guess you like

Origin blog.csdn.net/chuancheng_zeng/article/details/109689657