Ce bogue ressemble beaucoup à # 5432 "pip install --upgrade pip casse pip, encore".
Environnement
J'utilise le gestionnaire de paquets Homebrew: Homebrew 2.1.89-07-23
La description
Dans l'installation originale brew install python
, /usr/local/bin/pip3
est un lien symbolique. Il atteint finalement son fichier cible: /usr/local/Cellar/python/3.7.4/bin/pip3
.
L' brew info python
recommande d'utiliser des liens symboliques non versionnés à /usr/local/opt/python/libexec/bin
: /usr/local/opt/python/libexec/bin/pip
est un lien symbolique vers /usr/local/Cellar/python/3.7.4/bin/pip3
.
pip install --upgrade pip
crée un nouveau fichier /usr/local/bin/pip
au lieu de mettre à jour la cible du lien symbolique, c'est-à-dire /usr/local/Cellar/python/3.7.4/bin/pip3
. De plus, ce dernier fichier n'est pas mis à jour.
Comme le PATH trouve /usr/local/opt/python/libexec/bin/pip
avant /usr/local/bin/pip
, tout échoue ...
Comportement prévisible
Lors de la mise pip
jour de /usr/local/bin/pip
devrait être un lien symbolique vers /usr/local/opt/python/libexec/bin/pip
.
Comment reproduire
pip
find -E /usr/local/ -type f -iregex '.*/pip[23]?' -print -delete
Réinstaller python
avec Homebrew
brew reinstall python
Vérifiez l'état de / usr / local / bin / pip *, etc. et recherchez les i-nœuds similaires.
NB: Notez qu'il n'y a pas de /usr/local/bin/pip
.
ls -li /usr/local/bin/pip*
ls -li /usr/local/opt/python/libexec/bin/pip
ls -li /usr/local/opt/python/libexec/bin/../../bin/pip3
ls -li /usr/local/bin/../Cellar/python/3.7.4/bin/pip3
Surclassement pip
avec pip
/usr/local/opt/python/libexec/bin/pip install --upgrade pip
Refaites l'étape 3 ci-dessus.
Essaie
/usr/local/bin/pip --version
Essaie
/usr/local/opt/python/libexec/bin/pip --version
Production
pommeau:~ bouge$ find -E /usr/local/ -type f -iregex '.*/pip[23]?' -print -delete
/usr/local//bin/pip3
/usr/local//bin/pip
find: /usr/local//etc/FileWaveInstallers/FlatPackage-Microsoft_Office_2019_VL_Serializer.pkg: Permission denied
find: /usr/local//etc/FileWaveInstallers/FlatPackage-Microsoft_AutoUpdate_4.3.18090901_Updater.pkg: Permission denied
find: /usr/local//etc/FileWaveInstallers/FlatPackage-Microsoft_Office_16.17.18090901_Installer.pkg: Permission denied
/usr/local//Cellar/python/3.7.4/bin/pip3
pommeau:~ bouge$ brew reinstall python
==> Reinstalling python
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.4.mojave.bottle.
Already downloaded: /Users/bouge/Library/Caches/Homebrew/downloads/ffcfe300e2ad205387a2bdd27185d98d64621578d26d2f6ccbbcd091ff799fc8--python-3.7.4.mojave.bottle.tar.gz
==> Pouring python-3.7.4.mojave.bottle.tar.gz
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install
==> Caveats
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python<strong i="24">@2</strong>
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺 /usr/local/Cellar/python/3.7.4: 3,869 files, 60MB
pommeau:~ bouge$ ls -li /usr/local/bin/pip*
17870036 lrwxr-xr-x 1 bouge wheel 34B 4 mar 14:11 /usr/local/bin/pip2@ -> ../Cellar/python@2/2.7.16/bin/pip2
17870037 lrwxr-xr-x 1 bouge wheel 36B 4 mar 14:11 /usr/local/bin/pip2.7@ -> ../Cellar/python@2/2.7.16/bin/pip2.7
36689213 lrwxr-xr-x 1 bouge wheel 31B 24 jul 15:54 /usr/local/bin/pip3@ -> ../Cellar/python/3.7.4/bin/pip3
36689214 lrwxr-xr-x 1 bouge wheel 33B 24 jul 15:54 /usr/local/bin/pip3.7@ -> ../Cellar/python/3.7.4/bin/pip3.7
12675428 -rwxr-xr-x@ 1 bouge wheel 263B 16 jan 2019 /usr/local/bin/pip_upgrade_outdated*
pommeau:~ bouge$ ls -li /usr/local/opt/python/libexec/bin/pip
36689211 lrwxr-xr-x 1 bouge staff 14B 24 jul 15:54 /usr/local/opt/python/libexec/bin/pip@ -> ../../bin/pip3
pommeau:~ bouge$ ls -li /usr/local/opt/python/libexec/bin/../../bin/pip3
36689157 -rwxr-xr-x 1 bouge staff 386B 24 jul 15:54 /usr/local/opt/python/libexec/bin/../../bin/pip3*
pommeau:~ bouge$ ls -li /usr/local/bin/../Cellar/python/3.7.4/bin/pip3
36689157 -rwxr-xr-x 1 bouge staff 386B 24 jul 15:54 /usr/local/bin/../Cellar/python/3.7.4/bin/pip3*
pommeau:~ bouge$ /usr/local/opt/python/libexec/bin/pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.1.1
Uninstalling pip-19.1.1:
Successfully uninstalled pip-19.1.1
Successfully installed pip-19.2.1
pommeau:~ bouge$ ls -li /usr/local/bin/pip*
36690799 -rwxr-xr-x 1 bouge wheel 234B 24 jul 15:55 /usr/local/bin/pip*
17870036 lrwxr-xr-x 1 bouge wheel 34B 4 mar 14:11 /usr/local/bin/pip2@ -> ../Cellar/python@2/2.7.16/bin/pip2
17870037 lrwxr-xr-x 1 bouge wheel 36B 4 mar 14:11 /usr/local/bin/pip2.7@ -> ../Cellar/python@2/2.7.16/bin/pip2.7
36690800 -rwxr-xr-x 1 bouge wheel 234B 24 jul 15:55 /usr/local/bin/pip3*
36690801 -rwxr-xr-x 1 bouge wheel 234B 24 jul 15:55 /usr/local/bin/pip3.7*
12675428 -rwxr-xr-x@ 1 bouge wheel 263B 16 jan 2019 /usr/local/bin/pip_upgrade_outdated*
pommeau:~ bouge$ ls -li /usr/local/opt/python/libexec/bin/pip
36689211 lrwxr-xr-x 1 bouge staff 14B 24 jul 15:54 /usr/local/opt/python/libexec/bin/pip@ -> ../../bin/pip3
pommeau:~ bouge$ ls -li /usr/local/opt/python/libexec/bin/../../bin/pip3
36689157 -rwxr-xr-x 1 bouge staff 386B 24 jul 15:54 /usr/local/opt/python/libexec/bin/../../bin/pip3*
pommeau:~ bouge$ ls -li /usr/local/bin/../Cellar/python/3.7.4/bin/pip3
36689157 -rwxr-xr-x 1 bouge staff 386B 24 jul 15:54 /usr/local/bin/../Cellar/python/3.7.4/bin/pip3*
pommeau:~ bouge$ /usr/local/bin/pip --version
pip 19.2.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
pommeau:~ bouge$ /usr/local/opt/python/libexec/bin/pip --version
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 583, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 900, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 791, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 19.2.1 (/usr/local/lib/python3.7/site-packages), Requirement.parse('pip==19.1.1'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/opt/python/libexec/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3241, in <module>
<strong i="25">@_call_aside</strong>
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 585, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==19.1.1' distribution was not found and is required by the application
Pourriez-vous signaler un problème avec Homebrew, en créant un lien vers celui-ci?
Je pense qu'ils sont mieux placés pour résoudre ce problème que les responsables de pip. Nous serons heureux de travailler avec eux pour résoudre ce problème s'ils pensent que pip en amont devrait faire quelque chose.
J'ai toujours pensé que Homebrew devrait patcher pip, donc le message recommande brew upgrade pip
au lieu de la commande (intégrée) pip install
. Je pense que Debian le fait déjà (je ne suis pas sûr de RPM).
pip pourrait rendre cela plus facile par exemple en faisant de la chaîne de commande une variable globale (au lieu d'enfouir en ligne dans _internal.utils.outdated
), mais d'abord Homebrew doit être prêt à accepter le correctif.
Les étapes ci-dessous ont résolu mon problème. Partagez-le au cas où quelqu'un en aurait besoin:
cp /usr/local/opt/python/libexec/bin/pip /usr/local/opt/python/libexec/bin/pip_ORIG
mv /usr/local/bin/pip /usr/local/opt/python/libexec/bin/pip
ln -s /usr/local/opt/python/libexec/bin/pip /usr/local/bin/pip
pip --version
Crédit à cet article.
Veuillez envisager de soumettre un problème à Homebrew
Travail amateur ...
Commentaire le plus utile
Les étapes ci-dessous ont résolu mon problème. Partagez-le au cas où quelqu'un en aurait besoin:
Crédit à cet article.