[Python-ideas] install pip packages from Python prompt

Wes Turner wes.turner at gmail.com
Sat Nov 4 10:16:08 EDT 2017

On Saturday, November 4, 2017, Erik Bray <erik.m.bray at gmail.com> wrote:

> On Nov 4, 2017 08:31, "Stephen J. Turnbull" <turnbull.stephen.fw at u.
> tsukuba.ac.jp
> <javascript:_e(%7B%7D,'cvml','turnbull.stephen.fw at u.tsukuba.ac.jp');>>
> wrote:
> Erik Bray writes:
>  > Nope.  I totally get that they don’t know what a shell or command prompt
>  > is.  THEY. NEED. TO. LEARN.
> Just to be clear I did not write this. Someone replying to me did.
> I'm going to go over all the different proposals in this thread and see if
> I can synthesize a list of options.

Here's are some of the challenges (both for a pip() function and a GUI):

- Create reproducible software environments
  - Log the pip CLI commands
  - Log whether a version was specified
  - Be able to replay that log:
    - Which inputs need to be escaped before passing them through to a
shell or exec*? (see: shlex.split())

- Please don't flood PyPi with unnecessary requests
  - (Turns out there are 5 invocations of `!pip install' buried somewhere
in a script that's run 5 times in a hour by 25 students: even with pip
caching package downloads, how many HTTP requests is that? Who pays for

- There are a number of GUIs for pip: web-based, GUI based, CLI wrappers:
  - web:
  - CLI wrappers: pipenv, pipsi; ``conda install pip``
  - GUI: PyCharm
    - Tcl/Tk is in the standard library.
    - ``conda install spyder`` installs At

- pip does not have a stable API.
  - not even pip.main()
  - what about the shell CLI?
    - sarge is still safer than shlex.split()

>  I think, even if it's not a solution that winds up in the stdlib, it
> would be good to have some user stories about how package installation from
> within an interactive prompt might work (even if not from the standard
> REPL, which it should be noted has had small improvements made to it over
> the years).

This works today but is inadvisable because it risks wasting bandwidth if
the %run (!) instructions are frequently re-run unnecessarily:

$ ipython
>>> !pip install -U ipython
>>> exit()
$ ipython

> I also have my doubts about whether this *shouldn't* be possible. I mean,
> to a lot of beginners starting out the basic REPL *is* Python. They're so
> new to the scene they don't even know what IPython or Jupyter is or why
> they might want that. They aren't experienced enough to even know what
> they're missing out on. In classrooms we can resolve that easily by
> pointing our students to whatever tools we think will work best for them,
> but not everyone has that privilege.


$ conda install -y pip ipython notebook spyder

Or, just:

$ conda install -y ipython notebook

> Best,
> Erik
> I don't want to take a position on the proposal, and I agree that we
> should *strongly* encourage everyone to learn.  But "THEY. NEED. TO.
> LEARN." is not obvious to me.
> Anecdotally, my students are doing remarkably (to me, as a teacher)
> complex modeling with graphical interfaces to statistical and
> simulation packages (SPSS/AMOS, Artisoc, respectively), and collection
> of large textual databases from SNS with cargo-culted Python programs.
> For the past twenty years teaching social scientists, these accidental
> barriers (as Fred Brooks would have called them) have dropped
> dramatically, to the point where it's possible to do superficially
> good-looking (= complex) but entirely meaningless :-/ empirical
> research.  (In some ways I think this lowered cost has been horribly
> detrimental to my work as an educator in applied social science. ;-)
> The point being that "user-friendly" UI in many fields where (fairly)
> advanced computing is used is more than keeping up with the perceived
> needs of most computer users, while the essential (in the sense of
> Brooks) non-computing modeling difficulties of their jobs remain.
> By "perceived" I mean I want my students using TeX, but it's hard to
> force them when all their professors (except me and a couple
> mathematicians) use Word (speaking of irreproducible results).  It's
> good enough for government work, and that's in fact where many of them
> end up (and the great majority are either in government or in
> equivalent corporate bureaucrat positions).  Yes, I meant the
> deprecatory connotations of "perceived", but realistically, I admit
> that maybe they *don't* *need* the more polished tech that I could
> teach them.
> I remember when I first started out teaching Software Carpentry I made the
> embarrassing mistake (coming from Physics) of assuming that LaTex is
> de-facto in most other academic fields :)
>  > Hiding it is not a good idea for anyone.
> Agreed.  Command lines and REPLs teach humility, to me as well as my
> students. :-)
> Steve
> --
> Associate Professor              Division of Policy and Planning Science
> http://turnbull/sk.tsukuba.ac.jp/     Faculty of Systems and Information
> Email: turnbull at sk.tsukuba.ac.jp
> <javascript:_e(%7B%7D,'cvml','turnbull at sk.tsukuba.ac.jp');>
>      University of Tsukuba
> Tel: 029-853-5175                 Tennodai 1-1-1, Tsukuba 305-8573 JAPAN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171104/bb1091ee/attachment.html>

More information about the Python-ideas mailing list