[Python-ideas] install pip packages from Python prompt
Alex Walters
tritium-list at sdamon.com
Sun Oct 29 15:45:54 EDT 2017
Then those users have more fundamental problems. There is a minimum level of computer knowledge needed to be successful in programming. Insulating users from the reality of the situation is not preparing them to be successful. Pretending that there is no system command prompt, or shell, or whatever platform specific term applies, only hurts new programmers. Give users an error message they can google, and they will be better off in the long run than they would be if we just ran pip for them.
From: Stephan Houben [mailto:stephanh42 at gmail.com]
Sent: Sunday, October 29, 2017 3:43 PM
To: Alex Walters <tritium-list at sdamon.com>
Cc: Python-Ideas <python-ideas at python.org>
Subject: Re: [Python-ideas] install pip packages from Python prompt
Hi Alex,
2017-10-29 20:26 GMT+01:00 Alex Walters <tritium-list at sdamon.com <mailto:tritium-list at sdamon.com> >:
return “Please run pip from your system command prompt”
The target audience for my proposal are people who do not know
which part of the sheep the "system command prompt" is.
Stephan
From: Python-ideas [mailto:python-ideas-bounces+tritium-list <mailto:python-ideas-bounces%2Btritium-list> =sdamon.com at python.org <mailto:sdamon.com at python.org> ] On Behalf Of Stephan Houben
Sent: Sunday, October 29, 2017 3:19 PM
To: Python-Ideas <python-ideas at python.org <mailto:python-ideas at python.org> >
Subject: [Python-ideas] install pip packages from Python prompt
Hi all,
Here is in somewhat more detail my earlier proposal for
having in the interactive Python interpreter a `pip` function to
install packages from Pypi.
Motivation: it appears to me that there is a category of newbies
for which "open a shell and do `pip whatever`" is a bit too much.
It would, in my opinion, simplify things a bit if they could just
copy-and-paste some text into the Python interpreter and have
some packages from pip installed.
That would simplify instructions on how to install package xyz,
without going into the vagaries of how to open a shell on various
platforms, and how to get to the right pip executable.
I think this could be as simple as:
def pip(args):
import sys
import subprocess
subprocess.check_call([sys.executable, "-m", "pip"] + args.split())
print("Please re-start Python now to use installed or upgraded packages.")
Note that I added the final message about restarting the interpreter
as a low-tech solution to the problem of packages being already
imported in the current Python session.
I would imagine that the author of package xyz would then put on
their webpage something like:
To use, enter in your Python interpreter:
pip("install xyz --user")
As another example, consider prof. Baldwin from Woolamaloo university
who teaches a course "Introductory Python programming for Sheep Shavers".
In his course material, he instructs his students to execute the
following line in their Python interpreter.
pip("install woolamaloo-sheepshavers-goodies --user")
which will install a package which will in turn, as dependencies,
pull in a number of packages which are relevant for sheep shaving but
which have nevertheless irresponsibly been left outside the stdlib.
Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171029/f75654a8/attachment-0001.html>
More information about the Python-ideas
mailing list