I'm currently using prefect to orchestrate some simple task in python. It's working fine until I get this error :
Traceback (most recent call last):
File "test.py", line 2, in <module>
from prefect import flow
File "/Users/.../.venv/lib/python3.8/site-packages/prefect/__init__.py", line 25, in <module>
from prefect.states import State
...
ImportError: cannot import name 'SecretField' from 'pydantic' (/Users/.../.venv/lib/python3.8/site-packages/pydantic/__init__.py)
It's seems I have the module install in my venv :
(.venv) User@user % pip show pydantic
Name: pydantic
Version: 2.3.0
Summary: Data validation using Python type hints
Home-page: None
Author: None
Author-email: Samuel Colvin <s@muelcolvin.com>, Eric Jolibois <em.jolibois@gmail.com>, Hasan Ramezani <hasan.r67@gmail.com>, Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>, Terrence Dorsey <terry@pydantic.dev>, David Montague <david@pydantic.dev>
License: None
Location: /Users.../.venv/lib/python3.8/site-packages
Requires: annotated-types, pydantic-core, typing-extensions
Required-by: prefect, fastapi
Where this could come from ?
That's because Prefect isn't compatible with pydantic>2
yet.
So, they've pinned the reqs to the versions less than 2 (check PR10144 for more details).
Try to install the latest
version of Perfect or downgrade your pydantic's to 1.10.11
:
pip install -U prefect
# or pip install pydantic==1.10.11