5 ms·
The real question is who runs python -m pip when there is a perfectly good /usr/bin/pip?
by verroq 6y ago
The real question is who runs python -m pip when there is a perfectly good /usr/bin/pip?
- coldtea 6y agoThat's an easy question to answer. python -m pip is often advised over pip or /usr/bin/pip, because it uses the version of pip associated with that particular major+minor python install. https://snarky.ca/why-you-should-use-python-m-pip/ https://snarky.ca/why-you-should-use-python-m-pip/
- travisoneill1 6y agoWait, but isn't the point of the article that it will not do that, and rather just run the pip.py in you current working directory?
- Sebb767 6y agoOnly in the (probably unlikely) case that you have a `pip.py` in your CWD. In all other cases, it will execute pip as intended.
- BiteCode_dev 6y agoEven with the other form, if pip imports anything named like a pyhon module in the dl dir, it will be imported. That's because the current dir is automatically added to the PATH, using -m only add pip.py to the attack surface.
- coldtea 6y agoIn the off chance that you have one, yes. But in 99.9999999% of cases it will do what you expect (whereas "pip install x" will be easier to use the wrong one if you have multiple Python versions).
- hansvm 6y agoGuilty as charged. Using the system pip in an environment that doesn't use the system python is a recipe for disaster.
- wyclif 6y agoSo is the common practice of running 'sudo pip install' which can create a world of pain.
- staticassertion 6y agoI do it all the time.
- spapas82 6y agoI do it on Windows using the python executor py. So I'll run something like py -2 or py -3 or even py -3.8 to start the correct version of python when I'm not inside a venv. Also the same goes for modules. Since I've installed youtube_dl in my global python 3 I'll always run it like py -3 -m youtube_dl and update it using py -3 -m pip install youtube-dl -U. Or to create a new python 2 venv (for whatever reason) py -2 -m virtualenv venv.
- dnautics 6y agofor a very long time (I don't use python as a daily driver, so not sure if it's still the case) guidance was to use `python -m pip` and if you tried to run `pip ...` it would explicitlytell you to run `python -m pip`. I regularly install python on clean systems and all of my scripts run `python -m pip`. Should I be changing?
- BiteCode_dev 6y agoYou should always use this form if outside a virtualenv.