Using `python -m pip install foo`makes sure the copy of `pip` looked up
and executed is the one installed for the interpreter copy currently in
use (be it a system-wide or a virtualenv's)
This reduces the chances of failure (wrong `pip`gets used and the install
fails confusing the user or even worse the intended install action
succeeds but against another copy of Python) in broken setups in which a
leftover Python2 `pip` or one associated with a different Python 3.x
install is located in a directory which appears earlier in `$PATH`.
Inspired by this article by Brett Cannon: https://snarky.ca
/deconstructing-xkcd-com-1987/
Quoting:
> Having `pip` installed is not a shocker. The real question is ''what''
interpreter pip is attached to? That's dependent on which Python
interpreter was installed '''last''' in the ''earliest'' directory to have
a Python interpreter in it. This is why you should always use `python -m
pip` when executing pip to guarantee you are using pip with the
interpreter you intend to install for.
--
Ticket URL: <https://code.djangoproject.com/ticket/30367>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Ramiro Morales
* status: new => assigned
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/30367#comment:1>
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
Comment:
I think this makes sense. It's a bit more verbose, but removes a source of
errors that are particularly hard to debug for beginners.
--
Ticket URL: <https://code.djangoproject.com/ticket/30367#comment:2>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/30367#comment:3>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/30367#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"aed89adad54a977829c4f180b036033e031ebcc7" aed89ada]:
{{{
#!CommitTicketReference repository=""
revision="aed89adad54a977829c4f180b036033e031ebcc7"
Fixed #30367 -- Changed "pip install" to "python -m pip install" in docs,
comments and hints.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30367#comment:5>
Comment (by Carlton Gibson <carlton@…>):
In [changeset:"429d089d0a8fbd400e0c010708df4f0d16218970" 429d089]:
{{{
#!CommitTicketReference repository=""
revision="429d089d0a8fbd400e0c010708df4f0d16218970"
Refs #30367 -- Changed remaining "pip install" to "python -m pip install"
in docs.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30367#comment:6>
Comment (by Carlton Gibson <carlton.gibson@…>):
In [changeset:"6165e23776b146a587ee21bc468b1e645b4dd890" 6165e237]:
{{{
#!CommitTicketReference repository=""
revision="6165e23776b146a587ee21bc468b1e645b4dd890"
[3.1.x] Refs #30367 -- Changed remaining "pip install" to "python -m pip
install" in docs.
Backport of 429d089d0a8fbd400e0c010708df4f0d16218970 from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30367#comment:7>