1 votos

¿Conflicto de ZSH con los extras de Python setuptools y pip?

He instalado Python 3.9.7 usando pyenv. Luego he instalado un paquete webchanges que tiene dependencias opcionales que deben instalarse utilizando setuptools extras y pip formato:

pip install --upgrade webchanges[use_browser]
pip install --upgrade webchanges[use_browser,redis]

sin embargo al usar zsh obtengo este resultado:

$ python -m pip install --upgrade webchanges[use_browser]
zsh: no matches found: webchanges[use_browser]

al cambiar a bash el comando se completa sin problemas.

Me pregunto qué puede indicar el mensaje "no se han encontrado coincidencias" en relación con zsh. ¿Hay alguna configuración ambiental que pueda confundir zsh cuando se utiliza el setuptools extras y pip ¿Sintaxis?

aquí está el historial completo de comandos:

09/19/21_10:30:07 /Users/john
$ pip list
Package    Version
---------- -------
pip        21.2.4
setuptools 58.0.4

09/19/21_10:32:12 /Users/john
$ python -m pip install webchanges
Collecting webchanges
  Using cached webchanges-3.8.3-py3-none-any.whl (86 kB)
Collecting cssselect
  Using cached cssselect-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting lxml
  Using cached lxml-4.6.3-cp39-cp39-macosx_10_9_x86_64.whl (4.6 MB)
Collecting html2text
  Using cached html2text-2020.1.16-py3-none-any.whl (32 kB)
Collecting markdown2
  Using cached markdown2-2.4.1-py2.py3-none-any.whl (34 kB)
Collecting pyyaml
  Using cached PyYAML-5.4.1-cp39-cp39-macosx_10_9_x86_64.whl (259 kB)
Collecting requests
  Using cached requests-2.26.0-py2.py3-none-any.whl (62 kB)
Collecting msgpack
  Using cached msgpack-1.0.2-cp39-cp39-macosx_10_14_x86_64.whl (74 kB)
Collecting platformdirs
  Using cached platformdirs-2.3.0-py3-none-any.whl (13 kB)
Collecting charset-normalizer~=2.0.0
  Using cached charset_normalizer-2.0.6-py3-none-any.whl (37 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.6-py2.py3-none-any.whl (138 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2021.5.30-py2.py3-none-any.whl (145 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.2-py3-none-any.whl (59 kB)
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests, pyyaml, platformdirs, msgpack, markdown2, lxml, html2text, cssselect, webchanges
Successfully installed certifi-2021.5.30 charset-normalizer-2.0.6 cssselect-1.1.0 html2text-2020.1.16 idna-3.2 lxml-4.6.3 markdown2-2.4.1 msgpack-1.0.2 platformdirs-2.3.0 pyyaml-5.4.1 requests-2.26.0 urllib3-1.26.6 webchanges-3.8.3

09/19/21_10:32:32 /Users/john
$ python -m pip install --upgrade webchanges[use_browser]
zsh: no matches found: webchanges[use_browser]

09/19/21_10:35:44 /Users/john
$ bash

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash-3.2$ python -m pip install --upgrade webchanges[use_browser]
Requirement already satisfied: webchanges[use_browser] in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (3.8.3)
Requirement already satisfied: pyyaml in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from webchanges[use_browser]) (5.4.1)
Requirement already satisfied: lxml in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from webchanges[use_browser]) (4.6.3)
Requirement already satisfied: markdown2 in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from webchanges[use_browser]) (2.4.1)
Requirement already satisfied: platformdirs in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from webchanges[use_browser]) (2.3.0)
Requirement already satisfied: html2text in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from webchanges[use_browser]) (2020.1.16)
Requirement already satisfied: requests in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from webchanges[use_browser]) (2.26.0)
Requirement already satisfied: msgpack in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from webchanges[use_browser]) (1.0.2)
Requirement already satisfied: cssselect in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from webchanges[use_browser]) (1.1.0)
Collecting pyppeteer
  Using cached pyppeteer-0.2.6-py3-none-any.whl (83 kB)
Requirement already satisfied: urllib3<2.0.0,>=1.25.8 in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from pyppeteer->webchanges[use_browser]) (1.26.6)
Collecting importlib-metadata>=1.4
  Using cached importlib_metadata-4.8.1-py3-none-any.whl (17 kB)
Collecting appdirs<2.0.0,>=1.4.3
  Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting pyee<9.0.0,>=8.1.0
  Using cached pyee-8.2.2-py2.py3-none-any.whl (12 kB)
Collecting websockets<10.0,>=9.1
  Using cached websockets-9.1-cp39-cp39-macosx_10_9_x86_64.whl (88 kB)
Collecting tqdm<5.0.0,>=4.42.1
  Using cached tqdm-4.62.2-py2.py3-none-any.whl (76 kB)
Collecting zipp>=0.5
  Using cached zipp-3.5.0-py3-none-any.whl (5.7 kB)
Requirement already satisfied: charset-normalizer~=2.0.0 in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from requests->webchanges[use_browser]) (2.0.6)
Requirement already satisfied: idna<4,>=2.5 in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from requests->webchanges[use_browser]) (3.2)
Requirement already satisfied: certifi>=2017.4.17 in ./.pyenv/versions/3.9.7/lib/python3.9/site-packages (from requests->webchanges[use_browser]) (2021.5.30)
Installing collected packages: zipp, websockets, tqdm, pyee, importlib-metadata, appdirs, pyppeteer
Successfully installed appdirs-1.4.4 importlib-metadata-4.8.1 pyee-8.2.2 pyppeteer-0.2.6 tqdm-4.62.2 websockets-9.1 zipp-3.5.0
bash-3.2$

3voto

staffan Puntos 3299

TL,DR:

pip install --upgrade webchanges\[use_browser]

pip install --upgrade webchanges[use_browser] tiene casi el mismo significado en bash y zsh: webchanges[use_browser] es un patrón comodín ("glob"). Véase coincidencia de patrones en bash , Generación de nombres de archivos en zsh ). […] significa "un carácter, que es cualquiera de los caracteres entre los paréntesis". Así, si el directorio actual contiene los archivos

webchanges webchangesa webchangesb webchangesc webchangesd webchangese webchangeser zebchangese

entonces el shell ejecuta el comando

pip install --upgrade webchangesb webchangese

Donde bash y zsh difieren es en lo que ocurre cuando un patrón no coincide con ningún archivo. Bash (y otros shells compatibles con sh) pasan el patrón sin cambios al comando. Zsh, por defecto, señala un error.

La solución, en sh, bash o zsh, es citar el carácter especial [ ( cita de bash , citación de zsh ). Puede citar ] por simetría, pero no es necesario: sólo tiene un significado especial cuando hay un [ antes de que se cierre. Por ejemplo:

pip install --upgrade 'webchanges[use_browser]'
pip install --upgrade webchanges\[use_browser]
pip install --upgrade webchanges\[use_browser\]

También hay que citar < o > en un especificador de requisitos pip para que no se interprete como una indicación de redirección . En zsh también es necesario citar cualquiera de los signos de igualdad en == para evitar expansión equitativa si magic_equal_subst está activado y equals no está desactivado.

pip install webchanges\>1.2.3
pip install webchanges\>=1.2.3
pip install webchanges\==1.2.3
pip install webchanges=\=1.2.3

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X