[Python-ideas] install pip packages from Python prompt

Nathaniel Smith njs at pobox.com
Tue Oct 31 01:37:47 EDT 2017


On Mon, Oct 30, 2017 at 10:25 AM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> On Mon, Oct 30, 2017 at 11:44 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> ..
>> 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)
>
> This exact problem is solved rather elegantly in Julia.  When you
> upgrade a package that is already loaded in the REPL, it prints a
> warning:
>
> "The following packages have been updated but were already imported:
> ... Restart Julia to use the updated versions."
>
> listing the affected packages.
>
> See <https://github.com/JuliaLang/julia/blob/19921aa00468edf11f3d61f8c9b8d639ec71cd23/base/pkg/entry.jl#L564>.

This seems like the obvious solution to me too. Pip knows exactly
which files it modified. The interpreter knows which packages have
been imported. Having the REPL provide a friendly interface that ran
pip and then compared the lists would need some coordination between
the projects but wouldn't be rocket science, and would be *much* more
new-user-friendly than the current system.

(Also, I'm kind of grossed out by the attitude that it's a good thing
to drive people away by giving a bad first impression. Sure the shell
is worth learning, but it can wait until you actually need it. If you
make people fail for opaque reasons on basic tasks then the lesson
they learn isn't "oh I need to learn the shell", it's "oh I must be
stupid / maybe girls really can't do programming / I should give up".)

If you want to support conda too then cool, conda can install a
site.py that provides a conda() builtin that uses the same machinery.

-n

-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the Python-ideas mailing list