Hacker News new | ask | show | jobs
by randyrand 1372 days ago
why use -m?
2 comments

It ensures you're installing into environment using your current python. Useful in case the op already has a messed up environment where default pip doesn't use default python.
It's a good habit which ensures pip runs with the same interpreter as your `python` command.

One example (but there's many): On Windows a `pip install --upgrade pip` can't work as the OS would lock the `pip` executable, while a `python -m pip install --upgrade pip` works as the OS would lock python instead.

I also encontered environments (CI runners, things like this) with `python` and pip installed, installed but no `pip` shortcut.

More: https://snarky.ca/why-you-should-use-python-m-pip/