[QUESTION] Pydantic ImportError: cannot import name 'Field'
See original GitHub issueFirst, thanks for FastAPI! Great work here and this is fast indeed! We are thinking of using it instead of our actual framework.
Description
Is this normal I can’t import the class Field from Pydantic?
Additional context
This code:
from pydantic import BaseModel, Field
class BackbonePrefix(BaseModel):
mask: int = Field(ge=0, le=31)
…gives me this error:
ImportError: cannot import name 'Field'
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Why i can't import BaseModel from Pydantic? - Stack Overflow
ImportError: cannot import name 'BaseModel' from partially initialized module 'pydantic' (most likely due to a circular import) ...
Read more >ImportError: cannot import name 'ModelField' from 'pydantic ...
I run it inside an “env” as described in the README. The first problem was a missing dependency, but I could fix this...
Read more >ImportError: cannot import name 'Schema' from 'pydantic' - done
It appears that prodigy breaks when pydantic>=1.8 . This is because the pydantic. fields.
Read more >How to Fix : “ImportError: Cannot import name X” in Python?
You can solve the “ ImportError : Cannot import name X” Error by resolving the circular dependencies. You can do that either by...
Read more >tiangolo/fastapi - Gitter
import pydantic from typing import List, ForwardRef # Without this line: ... get an error: ImportError: cannot import name 'models' from 'fastapi_users' (....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the help here everyone! 👏 🙇
Thanks for reporting back and closing the issue @insideshell 👍
For everyone else, FastAPI has support for Pydantic version 1.0.0 and above since version
0.44.0
, so, make sure you update your FastAPI version and upgrade the Pydantic version as well ✔️Thanks, I saw this fix in another post, will try to fix it.