Pip: Installing pip for multiple Python versions does not work with symlinks

Created on 26 Jun 2018  路  7Comments  路  Source: pypa/pip

Environment

  • pip version: 10.0.1
  • Python version: 2.7.14 + 3.6.4
  • OS: MacOS High Sierra

Description

At the time of installation, pip, pipX, and pipX.Y will be written to /usr/local/bin. If there are existing symlinks, e.g. pip is symlinked to pipZ.W, this will overwrite pip executables for different versions and obviously break things.

Expected behavior

Remove the symlink and write a new file.

How to Reproduce

  1. Install pip for Python 2.7 (python get-pip.py)
  2. cd /usr/local/bin, rm pip, ln -s pip2.7 pip
  3. Install pip for Python 3.6 (python3 get-pip.py)

Output

pip2.7 is now running 3.6

auto-locked needs repro

All 7 comments

FWIW, you shouldn't really be using the MacOS provided Python for development since that might cause your OS to become unstable (if you make changes to packages which break something).

@pradyunsg I'm not using the system Python. In fact, the system python on High Sierra is 2.7.10, not 2.7.14

Ah. My bad. 馃槄

I can't reproduce this upgrading from 10.0.1 to 19.2.1 in a venv:


repro.sh

docker run -it python sh -c 'touch /usr/local/bin/pip2.7 && ln -sf pip2.7 /usr/local/bin/pip && ls -l /usr/local/bin && curl -o /get-pip.py https://bootstrap.pypa.io/get-pip.py && python /get-pip.py; ls -l /usr/local/bin'


Output

total 112
lrwxrwxrwx 1 root staff     8 Jun 27  2018 2to3 -> 2to3-3.6
-rwxr-xr-x 1 root staff   101 Jun 27  2018 2to3-3.6
-rwxr-xr-x 1 root staff   239 Jun 27  2018 easy_install
-rwxr-xr-x 1 root staff   239 Jun 27  2018 easy_install-3.6
lrwxrwxrwx 1 root staff     5 Jun 27  2018 idle -> idle3
lrwxrwxrwx 1 root staff     7 Jun 27  2018 idle3 -> idle3.6
-rwxr-xr-x 1 root staff    99 Jun 27  2018 idle3.6
lrwxrwxrwx 1 root staff     6 Aug 10 15:58 pip -> pip2.7
-rw-r--r-- 1 root staff     0 Aug 10 15:58 pip2.7
-rwxr-xr-x 1 root staff   221 Jun 27  2018 pip3
-rwxr-xr-x 1 root staff   221 Jun 27  2018 pip3.6
lrwxrwxrwx 1 root staff     6 Jun 27  2018 pydoc -> pydoc3
lrwxrwxrwx 1 root staff     8 Jun 27  2018 pydoc3 -> pydoc3.6
-rwxr-xr-x 1 root staff    84 Jun 27  2018 pydoc3.6
lrwxrwxrwx 1 root staff     7 Jun 27  2018 python -> python3
lrwxrwxrwx 1 root staff    14 Jun 27  2018 python-config -> python3-config
lrwxrwxrwx 1 root staff     9 Jun 27  2018 python3 -> python3.6
lrwxrwxrwx 1 root staff    16 Jun 27  2018 python3-config -> python3.6-config
-rwxr-xr-x 2 root staff 33024 Jun 27  2018 python3.6
lrwxrwxrwx 1 root staff    17 Jun 27  2018 python3.6-config -> python3.6m-config
-rwxr-xr-x 2 root staff 33024 Jun 27  2018 python3.6m
-rwxr-xr-x 1 root staff  3089 Jun 27  2018 python3.6m-config
lrwxrwxrwx 1 root staff    10 Jun 27  2018 pyvenv -> pyvenv-3.6
-rwxr-xr-x 1 root staff   441 Jun 27  2018 pyvenv-3.6
-rwxr-xr-x 1 root staff   218 Jun 27  2018 wheel
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1733k  100 1733k    0     0   9.9M      0 --:--:-- --:--:-- --:--:--  9.9M
Collecting pip
  Downloading https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl (1.4MB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 1.4MB 6.0MB/s
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-19.2.1
Killed
total 116
lrwxrwxrwx 1 root staff     8 Jun 27  2018 2to3 -> 2to3-3.6
-rwxr-xr-x 1 root staff   101 Jun 27  2018 2to3-3.6
-rwxr-xr-x 1 root staff   239 Jun 27  2018 easy_install
-rwxr-xr-x 1 root staff   239 Jun 27  2018 easy_install-3.6
lrwxrwxrwx 1 root staff     5 Jun 27  2018 idle -> idle3
lrwxrwxrwx 1 root staff     7 Jun 27  2018 idle3 -> idle3.6
-rwxr-xr-x 1 root staff    99 Jun 27  2018 idle3.6
-rwxr-xr-x 1 root staff   220 Aug 10 15:58 pip
-rw-r--r-- 1 root staff     0 Aug 10 15:58 pip2.7
-rwxr-xr-x 1 root staff   220 Aug 10 15:58 pip3
-rwxr-xr-x 1 root staff   220 Aug 10 15:58 pip3.6
lrwxrwxrwx 1 root staff     6 Jun 27  2018 pydoc -> pydoc3
lrwxrwxrwx 1 root staff     8 Jun 27  2018 pydoc3 -> pydoc3.6
-rwxr-xr-x 1 root staff    84 Jun 27  2018 pydoc3.6
lrwxrwxrwx 1 root staff     7 Jun 27  2018 python -> python3
lrwxrwxrwx 1 root staff    14 Jun 27  2018 python-config -> python3-config
lrwxrwxrwx 1 root staff     9 Jun 27  2018 python3 -> python3.6
lrwxrwxrwx 1 root staff    16 Jun 27  2018 python3-config -> python3.6-config
-rwxr-xr-x 2 root staff 33024 Jun 27  2018 python3.6
lrwxrwxrwx 1 root staff    17 Jun 27  2018 python3.6-config -> python3.6m-config
-rwxr-xr-x 2 root staff 33024 Jun 27  2018 python3.6m
-rwxr-xr-x 1 root staff  3089 Jun 27  2018 python3.6m-config
lrwxrwxrwx 1 root staff    10 Jun 27  2018 pyvenv -> pyvenv-3.6
-rwxr-xr-x 1 root staff   441 Jun 27  2018 pyvenv-3.6
-rwxr-xr-x 1 root staff   218 Jun 27  2018 wheel

Can you confirm if you're still able to reproduce this?

Hello! It's been some time, so I will close this issue. Please let us know if you're still having any problems. Thanks!

Hi @chrahunt , please see #5534

Well, I did not mean to reopen this. It should be closed

Was this page helpful?
0 / 5 - 0 ratings