How to check the root cause of the difference between “pytest” and “python -m pytest”?

CommandUses which Python?Risk
pytestWhatever executable is first in PATHMay run wrong environment
python -m pytestThe Python you explicitly calledMuch safer
cat $(which pytest)

The shebang line can show which “python” that pytest uses.

python -c "import sys; print(sys.executable)"

or

which python

This shows the interpreter you’re explicitly invoking.

Leave a Reply

Your email address will not be published. Required fields are marked *