Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#30367 closed Cleanup/optimization (fixed)

Docs: Change examples using bare `pip ...` to `python -m pip ...`

Reported by: Ramiro Morales Owned by: Ramiro Morales
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Perhaps a minor detail in these times in which Django is Python3-only and usage of some form of virtualenv/minimal container is ubiquitous. But posting for consideration anyways just in case.

Using python -m pip install foomakes 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 pipgets 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.

Change History (7)

comment:1 by Ramiro Morales, 5 years ago

Has patch: set
Owner: changed from nobody to Ramiro Morales
Status: newassigned

comment:2 by Tobias Kunze, 5 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

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.

comment:3 by Ramiro Morales, 5 years ago

Patch needs improvement: unset

comment:4 by Tobias Kunze, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In aed89ada:

Fixed #30367 -- Changed "pip install" to "python -m pip install" in docs, comments and hints.

comment:6 by Carlton Gibson <carlton@…>, 3 years ago

In 429d089:

Refs #30367 -- Changed remaining "pip install" to "python -m pip install" in docs.

comment:7 by Carlton Gibson <carlton.gibson@…>, 3 years ago

In 6165e237:

[3.1.x] Refs #30367 -- Changed remaining "pip install" to "python -m pip install" in docs.

Backport of 429d089d0a8fbd400e0c010708df4f0d16218970 from master.

Note: See TracTickets for help on using tickets.
Back to Top