Daniel
07/01/2025, 2:00 PMMarvin
07/01/2025, 2:00 PMMarvin
07/01/2025, 2:01 PMbash
pip install "pydantic<2.0"
2. Alternative Solution: Upgrade to Prefect 3.x, which is fully compatible with Pydantic 2.x
bash
pip install -U "prefect>=3.0"
For your current setup (Prefect 2.20.2), the first option (downgrading Pydantic) is the most straightforward fix. Prefect 2.x was built and tested with Pydantic 1.x, and while it might work with some Pydantic 2.x features, it's not guaranteed to be fully compatible.
To prevent similar issues in the future, you might want to consider:
1. Using a requirements.txt or poetry/pipenv to pin your dependencies
2. Upgrading to Prefect 3.x, which has been designed to work with newer versions of Pydantic
Would you like me to provide more specific guidance about upgrading to Prefect 3.x, or would you prefer details about pinning your dependencies in Prefect 2.x?Daniel
07/01/2025, 2:16 PMMarvin
07/01/2025, 2:16 PMMarvin
07/01/2025, 2:17 PMbash
pip install "pydantic<2.11.4"
This is the easiest solution and should work with your other packages that require Pydantic 2.x.
2. Upgrade to Prefect 3.x (only if option 1 doesn't work for you)
bash
pip install -U "prefect>=3.0"
I apologize for my earlier response suggesting downgrading to Pydantic 1.x - that was overly cautious advice. You're correct that Prefect 2.x has been working with Pydantic 2.x, and the issue you're experiencing is specifically related to the very latest Pydantic release (2.11.4).
Try the first option of pinning Pydantic to 2.11.3 - this should resolve the error while maintaining compatibility with your other packages that require Pydantic 2.x.