[Python-ideas] install pip packages from Python prompt

Antoine Pitrou solipsis at pitrou.net
Mon Oct 30 11:53:11 EDT 2017


On Tue, 31 Oct 2017 01:44:10 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:
> 
> A few specific notes here:
> 
> 1. As you say, this sort of already works in notebooks, since instructors
> can say to run "!pip install requests" and then restart the language kernel.
> 2. We could probably replicate that style in IDLE, since that runs user
> code in a subprocess, similar to the way Jupyter language kernels are
> separate from the frontend client
> 3. We can't replicate it as readily in the regular REPL, since that runs
> Python code directly in the current process, but even there I believe we
> could potentially trigger a full process restart via execve (or the C++
> style _execve on Windows)
> 
> (We'd want a real process restart, rather than emulating it by calling
> Py_Initialize & Py_Finalize multiple times, as not every module properly
> supports multiple initialise/finalise cycles within a single process, and
> module-specific quirks are exactly what we'd be trying to avoid by forcing
> an interpreter restart)

The main difference, though, is that a notebook will reload and
replay all your session, while restarting the regular REPL will simply
lose all current work.  I think that makes the idea much less
appealing.

Regards

Antoine.




More information about the Python-ideas mailing list