Error when starting the fast api application #7824
-
Error when starting the fast api application: Traceback (most recent call last): |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments
-
Can you define your environment? Python version and installed packages: python --version
python -m pip freeze |
Beta Was this translation helpful? Give feedback.
-
Running into the same issue. I wonder if it's related to Python 3.8 because it started happening when I upgraded my Docker container to Version: Packages:
|
Beta Was this translation helpful? Give feedback.
-
@AndreiToader1 I found the issue. FastAPI doesn't work w/ pydantic v1. Modifying my requirements to See https://gitter.im/tiangolo/fastapi?at=5db558949c39821509922795 |
Beta Was this translation helpful? Give feedback.
-
For what it’s worth, the pydantic v1 was almost certainly the source of the issue, but as of v0.44 fastapi now does support pydantic v1. Be aware there are a number of breaking changes that you may need to address when you upgrade to pydantic v1. |
Beta Was this translation helpful? Give feedback.
-
Sorry for the late response guys. I also solved the problem by changing the version of Pydantic. Since I'm new to python took me a while to figure it out. Thanks |
Beta Was this translation helpful? Give feedback.
-
Have the same issue after 0.45.0 release.
And after it i getting this: Traceback (most recent call last):
File "C:/Users/gosha/PycharmProjects/nw_backend/main.py", line 4, in <module>
from newwheel_backend.fastapi_app_instance import app as initial_app
File "C:\Users\gosha\PycharmProjects\nw_backend\newwheel_backend\fastapi_app_instance.py", line 1, in <module>
from fastapi import FastAPI
File "C:\Users\gosha\PycharmProjects\sas\venv\lib\site-packages\fastapi\__init__.py", line 7, in <module>
from .applications import FastAPI
File "C:\Users\gosha\PycharmProjects\sas\venv\lib\site-packages\fastapi\applications.py", line 3, in <module>
from fastapi import routing
File "C:\Users\gosha\PycharmProjects\sas\venv\lib\site-packages\fastapi\routing.py", line 6, in <module>
from fastapi import params
File "C:\Users\gosha\PycharmProjects\sas\venv\lib\site-packages\fastapi\params.py", line 14, in <module>
class Param(Schema):
TypeError: function() argument 1 must be code, not str My python version is 3.7.5. I can solve the problem only by downgrading the version of Pydantic back to 0,32.0. |
Beta Was this translation helpful? Give feedback.
-
@ShagonRU It looks like there might be something messed up in your environment -- try adding |
Beta Was this translation helpful? Give feedback.
-
@dmontagu |
Beta Was this translation helpful? Give feedback.
-
Thanks @prostomarkeloff and @dmontagu for the help here! 🍰 🎉 I think the original problem was solved, right @AndreiToader1 ? |
Beta Was this translation helpful? Give feedback.
-
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues. |
Beta Was this translation helpful? Give feedback.
@ShagonRU It looks like there might be something messed up in your environment -- try adding
from fastapi import __version__; print(__version__)
somewhere in yourfastapi_app_instance.py
. And make sure the actual runtime version of fastapi is the same as the version you just installed.