When you upgrade pip3
from 9.0.3 to 10.0.0 pip3
installs an additional pip
binary. This causes a conflict with coexistence of Python 2.7.x installations; contrary to the Python project's intentions. From the Python project's README file:
Python 3 and Python 2 Co-existence
Python.org Python 3.6 and 2.7.x versions can both be installed on your system and will not conflict. Command names for Python 3 contain a 3 in them, python3 (or python3.6), idle3 (or idle3.6), pip3 (or pip3.6), etc. Python 2.7 command names contain a 2 or no digit: python2 (or python2.7 or python), idle2 (or idle2.7 or idle), etc.
The release notes for Python2.7.14 have a similarly worded note on Python 3 and Python 2 co-existence.
For additional reference see: https://bugs.python.org/issue33290
gilw-mbp:bin gilw$ ls -al pip*
-rwxrwxr-x 1 root admin 253 Apr 17 09:21 pip3
-rwxrwxr-x 1 root admin 253 Apr 17 09:21 pip3.6
gilw-mbp:bin gilw$ pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl (1.3MB)
100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 1.3MB 1.0MB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-10.0.0
gilw-mbp:bin gilw$ ls -al pip*
-rwxr-xr-x 1 gilw admin 263 Apr 17 09:23 pip
-rwxr-xr-x 1 gilw admin 263 Apr 17 09:23 pip3
-rwxr-xr-x 1 gilw admin 263 Apr 17 09:23 pip3.6
This bites me regularly. Since the Python 3 installer does not install a 'pip' binary (only 'pip3'), something like 'pip3 install -U pip' should not either.
See also https://github.com/python/cpython/pull/6683 and https://bugs.python.org/issue33290 (showing that the CPython team does consider this a bug).
@pfmoore @ncoghlan Any thoughts on how we could achieve this?
I'm not sure if not installing pip
on Python 3 as a solution here (because that's what we want in virtual environments).
But pip can tell whether it's installing into a virtualenv or not, right?
The way we handle this in ensurepip is via a separate --default-pip
flag that controls whether or not the pip
command gets installed: https://docs.python.org/3/library/ensurepip.html#command-line-interface
To actually let that work, there's a bunch of special casing in https://github.com/pypa/pip/blob/0ae0109901f63b7f133229a9fee41332dd7366b4/src/pip/_internal/wheel.py#L390 that checks the ENSUREPIP_OPTIONS
environment variable when installing pip
itself.
So I think to improve this situation, the key would be to change the way that special casing works when ENSUREPIP_OPTIONS
isn't set.
Specifically, what I would suggest is that when outside a virtual environment, pip
could check for shutil.which('python') == sys.executable
, and if that's not true, then treat it like ENSUREPIP_OPTIONS=install
(thus setting pipX
and pipX.Y
, but not pip
)
I'm hesitant to add even more special casing for pip here, especially one that I think is just going to shift some of the confusion around and make some cases better and some worse. This is realistically a special case of the issues described in https://github.com/pypa/pip/issues/3164, so I'm going to close this in favor of further discussion over there.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I'm hesitant to add even more special casing for pip here, especially one that I think is just going to shift some of the confusion around and make some cases better and some worse. This is realistically a special case of the issues described in https://github.com/pypa/pip/issues/3164, so I'm going to close this in favor of further discussion over there.