This is a duplicate, I know. Nothing helps, however. I just want the equivalent of this:
$ pip install pydantic[email]
I've read all the relevant posts. Now my pyproject.toml looks like this (I tried everything else, too):
[tool.poetry.dependencies]
pydantic = {version = "*", optional = true, extras = ["email"]}
...
[tool.poetry.extras]
email = ["pydantic"]
I also removed .venv, and poetry.lock, then $ poetry install. No use. The runtime error is clear:
ImportError: email-validator is not installed, run `pip install pydantic[email]`
I can add one detail: pydantic itself is a dependency (it was absent from pyproject.toml before I ran into this problem).
poetry add 'pydantic[email]'then look at the content ofpyproject.toml. - sinorocpydantic = {extras = ["email"], version = "^1.8.2"}. And it works. It looks like I tried it too, manually :) .[tool.poetry.extras]section is not needed any more? - Alexey Orlov[tool.poetry.extras]in combination withoptional = trueis if your project (library or application) has "extras" itself. So in your case, you don't need those. - sinoroc