<p>instalar pip - actualizar pip rompe pip</p>

Creado en 24 jul. 2019  ·  6Comentarios  ·  Fuente: pypa/pip

Este error se parece mucho a # 5432 "pip install --upgrade pip rompe pip, still".

Medio ambiente

  • versión pip: pip 19.2.1 de /usr/local/lib/python3.7/site-packages/pip (python 3.7)
  • Versión de Python: Python 3.7.4
  • Sistema operativo: MacOS Mojave 10.14.5 (18F132)

Utilizo el administrador de paquetes Homebrew: Homebrew 2.1.89-07-23

Descripción

En la instalación original brew install python , /usr/local/bin/pip3 es un enlace simbólico. Finalmente llega a su archivo de destino: /usr/local/Cellar/python/3.7.4/bin/pip3 .

La brew info python recomienda usar enlaces simbólicos no versionados en /usr/local/opt/python/libexec/bin : /usr/local/opt/python/libexec/bin/pip es un enlace simbólico a /usr/local/Cellar/python/3.7.4/bin/pip3 .

pip install --upgrade pip crea un nuevo archivo /usr/local/bin/pip lugar de actualizar el destino del enlace simbólico, es decir, /usr/local/Cellar/python/3.7.4/bin/pip3 . Además, este último archivo no se actualiza.

Como PATH encuentra /usr/local/opt/python/libexec/bin/pip antes de /usr/local/bin/pip , todo falla ...

Comportamiento esperado

Al actualizar pip , /usr/local/bin/pip debe ser un enlace simbólico a /usr/local/opt/python/libexec/bin/pip .

Cómo reproducir

  1. Limpiar todos los pip
    find -E /usr/local/ -type f -iregex '.*/pip[23]?' -print -delete
  1. Reinstale python con Homebrew
    brew reinstall python

  2. Verifique el estado de / usr / local / bin / pip *, etc. y busque los i-nodos similares.
    NB: Tenga en cuenta que no hay /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
  1. Actualice pip con pip
    /usr/local/opt/python/libexec/bin/pip install --upgrade pip

  2. Rehaga el paso 3 anterior.

  3. Poner a prueba o probar
    /usr/local/bin/pip --version

  4. Poner a prueba o probar
    /usr/local/opt/python/libexec/bin/pip --version

Salida

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
crash macos downstream bug

Comentario más útil

Los siguientes pasos solucionaron mi problema. Compártelo en caso de que alguien lo necesite:

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édito a esta publicación.

Todos 6 comentarios

¿Podría presentar un problema con Homebrew, vinculando a este?

Creo que están en una mejor posición para abordar esto que los mantenedores de pip. Estaremos encantados de trabajar con ellos para resolver esto si hay algo que crean que debería hacer el pip upstream.

Siempre he sentido que Homebrew debería parchear pip, por lo que el mensaje recomienda brew upgrade pip lugar del comando pip install (integrado). Creo que Debian ya hace esto (no estoy seguro de RPM).

pip podría facilitarlo, por ejemplo, haciendo que la cadena de comandos sea una variable global (en lugar de estar enterrada en línea en _internal.utils.outdated ), pero primero Homebrew debe estar dispuesto a aceptar el parche.

Los siguientes pasos solucionaron mi problema. Compártelo en caso de que alguien lo necesite:

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édito a esta publicación.

Considere presentar un problema a Homebrew

Trabajo amateur ...

¿Fue útil esta página
0 / 5 - 0 calificaciones