[Python-ideas] install pip packages from Python prompt

Paul Moore p.f.moore at gmail.com
Sun Oct 29 16:42:46 EDT 2017


On 29 October 2017 at 19:40, Stephan Houben <stephanh42 at gmail.com> wrote:
> Hi Antoine,
>
> 2017-10-29 20:31 GMT+01:00 Antoine Rozo <antoine.rozo at gmail.com>:
>>
>> Hi,
>>
>> What would be the difference with current pip module?
>> pip.main(['install', 'some_package'])
>
>
>
> My understanding is that direct use of the `pip` module is explicitly not
> recommended.

Not only not recommended, but explicitly not supported. And it won't
be available at all in pip 10.

Having said that, I'm -1 on this proposal. Installing new modules (or
upgrading existing ones) in a running Python process has all sorts of
subtle issues - the need to reload already-loaded modules, the fact
that failed imports may have resulted in different code paths being
taken ("except ImportError"), etc. Exiting the Python process to run
pi avoids all of these.

For someone who doesn't understand the difference between the Python
REPL and the command prompt, offering an interface that exposes them
to these sort of potential issues won't actually help them. Better to
teach them the basics of what a command line is, and what an
interactive Python prompt is, before exposing them to subtleties like
this.

Paul


More information about the Python-ideas mailing list