PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`.
The error message you're seeing indicates that there is an issue with the usage of the @root_validator decorator from the Pydantic library. Starting from version 2.0.2, if you use @root_validator with pre=False (which is the default behavior), you must specify skip_on_failure=True to avoid this error.
File containing root_validator not found !
the tips below didn't help:
To resolve this issue, you have a few options:
-
Update Pydantic: Make sure you have the latest version of Pydantic installed. You can use pip install --upgrade pydantic to upgrade to the latest version.
-
Replace @root_validator with @model_validator: As mentioned in the error message, @root_validator is deprecated and should be replaced with @model_validator. Update your code to use @model_validator instead.
-
Specify skip_on_failure=True: If you want to continue using @root_validator, you can add the skip_on_failure=True parameter to the decorator. This will prevent the error from occurring. For example:
@root_validator(pre=False, skip_on_failure=True) def my_validator(cls, values): # Your validation logic here return values
Someone please help me in fixing this.
Thanks in advance :).
I keep getting the same error. Does anyone have a solution please?
Use pydantic following version Pydantic==1.10.7
I fixed this issue by using below command to install pydantic.
pip install pydantic==1.10.7
Now, Im getting: ImportError: cannot import name 'AfterValidator' from 'pydantic' (C:\Users\b..\Lib\site-packages\pydantic_init_.cp311-win_amd64.pyd)