zsh: no matches found - trying to install pydantic[email] [duplicate]
Asked Answered
S

1

9

After activating my venv and installing Pydantic through

pip install pydantic

I tried creating a new file as follows:

from pydantic import Basemodel, EmailStr

class Person(BaseModel):
      id: int
      name: str
      email: EmailStr

and was just running this file with the unused class. But it returned the following error:

ModuleNotFoundError: No module named 'email_validator'
.
.
.
ImportError: email-validator is not installed, run `pip install pydantic[email]`

When running the hint

pip install pydantic[email]

it tells me:

zsh: no matches found: pydantic[email]

Could someone help me with this stupid beginner error? Thanks!

I reinstalled Pydantic, recreated a venv, reactivated the venv.

Sidoney answered 5/1, 2023 at 17:44 Comment(1)
sorry not your fault but people have already encountered this pip-on-zsh issue before so looks like a duplicate. hopefully that fixed your issue though. welcome aboard.Heavy
M
21

This has nothing to do with Python, Pydantic, or your virtual environment. It tells you that this is a shell error by starting the error message with your shell's name zsh.

When you write ... pydantic[email], zsh interprets this as a glob pattern to match files named pydantic followed by either e, m, a, i, or l. It finds no files matching that pattern in your working directory and gives you that error.

To avoid this, you can simply put that argument in quotes like this:

pip install 'pydantic[email]'
Macklin answered 5/1, 2023 at 19:10 Comment(2)
Thanks @daniil for the explanation. this makes absolutely senseSidoney
pip install email-validatorDawn

© 2022 - 2024 — McMap. All rights reserved.