zsh: no matches found: requests[security]
Asked Answered
S

2

195

I am trying to run a python urllib2 script and getting this error:

InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

After googling the error the solution, on stack overflow is to download requests' security package:
pip install requests[security]

But when I run that I get the error...

zsh: no matches found: requests[security]

Anyone know why zsh isn't picking up this library, it installs/upgrades requests just fine, I don't know why this isn't working

I am running this on a Debian Server...

Sanford answered 29/5, 2015 at 22:6 Comment(1)
In addition to the excellent answer given by Lukas Graf: You can configure zsh a bit how to behave if a glob does not match. If you do a setopt nonomatch, and the glob can't be expanded, you don't get an error message and the pattern is left unchanged. I don't like this option (and have not enabled it), but some people do.Rube
T
606

zsh uses square brackets for globbing / pattern matching.

That means that if you need to pass literal square brackets as an argument to a command, you either need to escape them or quote the argument like this:

pip install 'requests[security]'

If you want to disable globbing for the pip command permanently, you can do so by adding this to your ~/.zshrc:

alias pip='noglob pip'
Tourcoing answered 29/5, 2015 at 22:23 Comment(6)
That works perfectly thank you, now I just need to make sure it installs into the correct location.Sanford
Came here for a similar error ``` ➜ pip install gym[box2d] zsh: no matches found: gym[box2d] ``` The correct way to use is ➜ pip install 'gym[box2d]'Zelda
Thank you for posting this! I looked high and low to figure out why my optional install was not working.Grinnell
Works like a charm! Just a note here, remember to restart zsh to make disabling globbing take effectExtravagate
isn't there a way to disable in ~/.zshrc for all commands (not just for pip)?Inpatient
I had python -m pip install -U channels["daphne"] and got the error: zsh: no matches found: channels[daphne] So I tried python3 -m pip install -U 'channels[daphne]' instead, and it worked.Sidedress
S
7

Use instead:

pip install requests\[security\]

Works flawlessly on MacOS with zsh.

Scrag answered 13/12, 2023 at 12:53 Comment(1)
This basically reiterates information from the older answer, though yes, it is true that you can use backslashes instead of quotes to prevent the shell from attempting to perform expansion on the value, at the expense of legibility.Saltwater

© 2022 - 2024 — McMap. All rights reserved.