r/Python • • Jul 21 '22

Resource Why you should use `python -m pip`

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

16 comments sorted by

11

u/benefit_of_mrkite Jul 21 '22 edited Jul 21 '22

I never use -m because I use virtual environments.

While in a venv, -m is pointless because I know python in that instance is the one in the venv while the venv is active.

So while I agree with this in principle I disagree with it in practice.

If you’re not using venvs you can absolutely hose your system python with dependencies.

And if you used to not use venvs but decide to later, implementing a new venv copies over every single package you ever installed as well as the python binary and other files.

10

u/Bangoga Jul 21 '22

You shouldn't. This is a pseudo-intellectual article. Use whatever you want

-1

u/Rawing7 Jul 21 '22

Uh, do you realize that the article contains arguments why python -m pip is sometimes better? How can you just respond "You shouldn't" without providing any counter-arguments?

-3

u/Bangoga Jul 21 '22

Don't well awkctually me. Use pip, use python -m pip. Use venv, use conda. Use what ever the hell you want to get your shit to run.

As long as you maintain a requirements.txt, no one cares and should care.

-1

u/Rawing7 Jul 21 '22

I didn't well actually you. I told you that you're a clown who spouts meaningless garbage instead of defending your opinion with arguments.

And that bit about using requirements.txt is honestly much worse advice than using python -m pip. Wanna know why? Too bad, I'm just gonna call you a pseudo-intellectual.

-3

u/Bangoga Jul 21 '22

Tell me you just learned programming without telling me you just learned programming.

1

u/Rawing7 Jul 21 '22

Tell me absolutely nothing while saying enough to fill 5 books.

-1

u/Bangoga Jul 21 '22

Talk like a proper anime profile user.

0

u/Rawing7 Jul 21 '22

Man, you live such a sad little life. All you can do is sling insults. Not even an attempt to have a productive conversation. Just various forms of "I'm better than you. I'm right, you're wrong." Insult after insult after insult. Sad.

-1

u/Bangoga Jul 21 '22

All facts no cap. Git gud.

2

u/ZachVorhies Jul 21 '22 edited Jul 21 '22

For those that don’t want to read the whole article this is the gist:

pip may be not point to the same command as python -m pip

This happens in windows and mac quite often. You’ll experience this as finding that pip install <package> won’t work for you. But python -m install <package> will.

If you are using virtual environments then this isn’t a problem, pip and python -m pip will point to the same command

1

u/Bangoga Jul 21 '22

So essentially "if you haven't set up pip on your windows, just use python -m pip instead"

Or just set up pip

1

u/ZachVorhies Jul 21 '22

or use a virtual environment. If using global python always use python -m pip <Package>

-1

u/Bangoga Jul 21 '22

I buy a new computer for every new project

2

u/[deleted] Jul 21 '22

I thought using pip as a module was discouraged?

As noted previously, pip is a command line program. While it is implemented in Python, and so is available from your Python code via import pip, you must not use pip’s internal APIs in this way. There are a number of reasons for this: ...


Ignoring that this text is written against using pip in python which isn't really what's meant by doing -m pip I still think this is silly.

Understand your environment and you won't have a problem. This approach is sort of the result of an X-Y problem.

1

u/MasterFarm772 Jul 21 '22

Ohh so that's the reason for the -m, good to know! Thanks for sharing :)