[Distutils] The future of invoking pip

Donald Stufft donald at stufft.io
Sat Nov 7 19:37:03 EST 2015

On November 7, 2015 at 7:22:23 PM, Antoine Pitrou (solipsis at pitrou.net) wrote:
> On Sat, 7 Nov 2015 19:16:55 -0500
> Donald Stufft wrote:
> >
> > The largest problem comes when ``python`` and ``pip`` disagree about which Python  
> is being invoked.
> As a said, this is a problem for package managers and distributions.
> "pip" isn't the only affected command, e.g. "pydoc" is as well.

Package managers and distributions aren’t the only place that Python comes from. People might have installed their own Python (such as via pyenv or even manually) or they may be using two different package managers one that comes with pip by default and one that doesn’t.

This probably does also affect pydoc but I would suggest that more people are invoking pip in various “weird” situation than are invoking pydoc. I know personally I’ve *never* invoked pydoc. In fact, the pyvenv script has been deprecated and is going to be removed in Python 3.8 in favor of `python -m venv` for similar reasons that I've described here.

> > What should the command be to install into PyPy 2.4.0?
> If you are using a virtualenv (or a conda environment, assuming you
> did a conda package for pypy), just "pip”.

And if you’re not using a virtual environment or a conda environment? If you have /usr/bin/python and /usr/bin/pypy how should I install something into PyPy? We can’t just pretend that the only time someone wants to install into PyPy is inside of a virtual environment.

> > What if someone has /usr/bin/python2.7
> > and /usr/bin/pip2.7 and they then install another Python 2.7
> > into /usr/local/bin/python2.7 but they don’t have pip installed there?
> Why wouldn't they? I thought the plan is to have "pip" bundled with
> every recent Python version? AFAIR someone even said it was a bug if pip
> wasn't installed together with Python…

Python 2.7.9+ and Python 3.4+ come with ensurepip which can be used to install pip into an environment. In Python 3.4+ it will be installed by default by the Makefile and by the OSX/Windows installers. In Python 2.7.9+ it’s only installed by default in the OSX/Windows installers but it is not in the Makefile. So how might they not get pip?

* They installed from a Makefile (or their distribution did) and they either accepted the 2.7 default or they disabled it when installing on 3.4.
* They are using a version of Python that didn’t come with pip.
* They uninstalled pip (because pip isn’t part of the standard library, it’s just another Python package that can be uninstalled or upgraded).
* They installed into a virtual environment that was created without pip being installed.

Donald Stufft
PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA

More information about the Distutils-SIG mailing list