Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.3 kB
3
Indexable
Never
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def root():
    return {"message": "Hello World"}


import uvicorn

if __name__ == "__main__":
    uvicorn.run(app)

Error-

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [115], in <cell line: 1>()
----> 1 from fastapi import FastAPI
      3 app = FastAPI()
      5 @app.get("/")
      6 async def root():

File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/fastapi/__init__.py:7, in <module>
      3 __version__ = "0.100.0"
      5 from starlette import status as status
----> 7 from .applications import FastAPI as FastAPI
      8 from .background import BackgroundTasks as BackgroundTasks
      9 from .datastructures import UploadFile as UploadFile

File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/fastapi/applications.py:16, in <module>
      1 from enum import Enum
      2 from typing import (
      3     Any,
      4     Awaitable,
   (...)
     13     Union,
     14 )
---> 16 from fastapi import routing
     17 from fastapi.datastructures import Default, DefaultPlaceholder
     18 from fastapi.exception_handlers import (
     19     http_exception_handler,
     20     request_validation_exception_handler,
     21     websocket_request_validation_exception_handler,
     22 )

File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/fastapi/routing.py:22, in <module>
      7 from enum import Enum, IntEnum
      8 from typing import (
      9     Any,
     10     Callable,
   (...)
     19     Union,
     20 )
---> 22 from fastapi import params
     23 from fastapi._compat import (
     24     ModelField,
     25     Undefined,
   (...)
     29     lenient_issubclass,
     30 )
     31 from fastapi.datastructures import Default, DefaultPlaceholder

File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/fastapi/params.py:8, in <module>
      5 from pydantic.fields import FieldInfo
      6 from typing_extensions import Annotated, deprecated
----> 8 from ._compat import PYDANTIC_V2, Undefined
     10 _Unset: Any = Undefined
     13 class ParamTypes(Enum):

File /Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/fastapi/_compat.py:297, in <module>
    291 from pydantic.fields import (  # type: ignore[no-redef,attr-defined]
    292     Undefined as Undefined,
    293 )
    294 from pydantic.fields import (  # type: ignore[no-redef, attr-defined]
    295     UndefinedType as UndefinedType,  # noqa: F401
    296 )
--> 297 from pydantic.networks import (  # type: ignore[no-redef]
    298     MultiHostDsn as MultiHostUrl,  # noqa: F401
    299 )
    300 from pydantic.schema import (
    301     field_schema,
    302     get_flat_models_from_fields,
    303     get_model_name_map,
    304     model_process_schema,
    305 )
    306 from pydantic.schema import (  # type: ignore[no-redef]  # noqa: F401
    307     get_annotation_from_field_info as get_annotation_from_field_info,
    308 )

ImportError: cannot import name 'MultiHostDsn' from 'pydantic.networks' (/Analytics/venv/CAPEANALYTICS/lib/python3.8/site-packages/pydantic/networks.cpython-38-x86_64-linux-gnu.so)