Closed Kimdow220807 closed 1 year ago
I believe it's because it didn't have a GET /
router. You can just open http://127.0.0.1:8888/docs for the Swagger-UI page.
In fact, I just added a home page router today. It simp return "Swagger-UI to: /docs" when you visit http://127.0.0.1:8888/.
我相信這是因為它沒有路由器
GET /
。您只需開啟http://127.0.0.1:8888/docs即可進入 Swagger-UI 頁面。事實上,我今天剛剛新增了一個主頁路由器。當您訪問http://127.0.0.1:8888/時,它只需返回“Swagger-UI to: /docs” 。
When I visit http://127.0.0.1:8888/docs, it still gives me an error. ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\uvicorn\protocols\http\httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call return await self.app(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\applications.py", line 292, in call await super().call(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\applications.py", line 122, in call await self.middleware_stack(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\middleware\errors.py", line 184, in call raise exc File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\middleware\errors.py", line 162, in call await self.app(scope, receive, _send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\middleware\exceptions.py", line 79, in call raise exc File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\middleware\exceptions.py", line 68, in call await self.app(scope, receive, sender) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\middleware\asyncexitstack.py", line 20, in call raise e File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\middleware\asyncexitstack.py", line 17, in call await self.app(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\routing.py", line 718, in call await route.handle(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\routing.py", line 276, in handle await self.app(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\routing.py", line 66, in app response = await func(request) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\applications.py", line 247, in openapi return JSONResponse(self.openapi()) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\applications.py", line 219, in openapi self.openapi_schema = get_openapi( File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\openapi\utils.py", line 475, in get_openapi field_mapping, definitions = get_definitions( File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi_compat.py", line 465, in get_definitions return {}, get_model_definitions( File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi_compat.py", line 364, in get_model_definitions m_schema, m_definitions, m_nested_models = model_process_schema( File "pydantic\schema.py", line 582, in pydantic.schema.model_process_schema File "pydantic\schema.py", line 623, in pydantic.schema.model_type_schema File "pydantic\schema.py", line 249, in pydantic.schema.field_schema File "pydantic\schema.py", line 217, in pydantic.schema.get_field_info_schema File "pydantic\schema.py", line 996, in pydantic.schema.encode_default File "pydantic\json.py", line 90, in pydantic.json.pydantic_encoder TypeError: Object of type 'File' is not JSON serializable
Did you used virtualenv or conda to isolate python enviroments?
I saw this error before, most likely because the pydantic package version conflict. Can you list the result of pip list
?
我相信這是因為它沒有路由器
GET /
。您只需開啟http://127.0.0.1:8888/docs即可進入 Swagger-UI 頁面。事實上,我今天剛剛新增了一個主頁路由器。當您訪問http://127.0.0.1:8888/時,它只需返回“Swagger-UI to: /docs” 。
When I visit http://127.0.0.1:8888/docs, it still gives me an error. ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\uvicorn\protocols\http\httptools_impl.py", line 426, in run_asgi result = await app( # type: ignore[func-returns-value] File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call return await self.app(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\applications.py", line 292, in call await super().call(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\applications.py", line 122, in call await self.middleware_stack(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\middleware\errors.py", line 184, in call raise exc File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\middleware\errors.py", line 162, in call await self.app(scope, receive, _send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\middleware\exceptions.py", line 79, in call raise exc File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\middleware\exceptions.py", line 68, in call await self.app(scope, receive, sender) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\middleware\asyncexitstack.py", line 20, in call raise e File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\middleware\asyncexitstack.py", line 17, in call await self.app(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\routing.py", line 718, in call await route.handle(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\routing.py", line 276, in handle await self.app(scope, receive, send) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\starlette\routing.py", line 66, in app response = await func(request) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\applications.py", line 247, in openapi return JSONResponse(self.openapi()) File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\applications.py", line 219, in openapi self.openapi_schema = get_openapi( File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi\openapi\utils.py", line 475, in get_openapi field_mapping, definitions = get_definitions( File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi_compat.py", line 465, in get_definitions return {}, get_model_definitions( File "C:\Users\OM-PC-089\AppData\Roaming\Python\Python310\site-packages\fastapi_compat.py", line 364, in get_model_definitions m_schema, m_definitions, m_nested_models = model_process_schema( File "pydantic\schema.py", line 582, in pydantic.schema.model_process_schema File "pydantic\schema.py", line 623, in pydantic.schema.model_type_schema File "pydantic\schema.py", line 249, in pydantic.schema.field_schema File "pydantic\schema.py", line 217, in pydantic.schema.get_field_info_schema File "pydantic\schema.py", line 996, in pydantic.schema.encode_default File "pydantic\json.py", line 90, in pydantic.json.pydantic_encoder TypeError: Object of type 'File' is not JSON serializable
你使用 virtualenv 或 conda 來隔離 python 環境嗎?
我之前看到過這個錯誤,很可能是因為 pydantic 套件版本衝突。你能列出 的結果嗎
pip list
?
Yes, I used conda; (FooocusAPI) D:\AIGC\Fooocus-API>pip list Package Version
absl-py 1.4.0 accelerate 0.21.0 addict 2.4.0 aiofiles 23.1.0 aiohttp 3.8.5 aiosignal 1.3.1 aiostream 0.4.5 albumentations 1.3.1 antlr4-python3-runtime 4.9.3 anyio 3.7.1 asgiref 3.7.2 astunparse 1.6.3 async-timeout 4.0.2 attrs 23.1.0 av 10.0.0 backoff 2.2.1 basicsr 1.4.2 beautifulsoup4 4.12.2 bidict 0.22.1 blinker 1.6.2 boltons 23.0.0 cachetools 5.3.1 certifi 2023.5.7 cffi 1.16.0 charset-normalizer 3.2.0 chroma-bullet 2.2.0 chroma-hnswlib 0.7.2 chroma-migrate 0.0.7 chromadb 0.3.29 click 8.1.6 clickhouse-connect 0.6.6 cn-clip 1.5.1 colorama 0.4.6 coloredlogs 15.0.1 contourpy 1.1.0 cookies 2.2.1 customtkinter 5.1.3 cycler 0.11.0 Cython 3.0.0 darkdetect 0.8.0 dataclasses-json 0.5.14 Deprecated 1.2.14 duckdb 0.7.1 easydict 1.10 einops 0.4.1 exceptiongroup 1.1.2 facexlib 0.3.0 fastapi 0.103.1 ffmpy 0.3.1 filelock 3.12.2 filterpy 1.4.5 Flask 2.3.2 Flask-SocketIO 5.3.5 Flask-SQLAlchemy 3.1.1 flatbuffers 23.5.26 fonttools 4.41.0 frozenlist 1.4.0 fsspec 2023.6.0 future 0.18.3 gast 0.4.0 gdown 4.7.1 gfpgan 1.3.8 google-auth 2.22.0 google-auth-oauthlib 1.0.0 google-pasta 0.2.0 googleapis-common-protos 1.60.0 gptcache 0.1.38 gradio 3.39.0 gradio_client 0.3.0 greenlet 2.0.2 h11 0.14.0 h5py 3.9.0 hnswlib 0.7.0 httpcore 0.17.3 httptools 0.6.0 httpx 0.24.1 huggingface-hub 0.16.4 humanfriendly 10.0 idna 3.4 imageio 2.31.1 importlib-metadata 6.8.0 importlib-resources 6.0.0 insightface 0.7.3 itsdangerous 2.1.2 jax 0.4.13 Jinja2 3.1.2 joblib 1.3.1 jsonschema 4.18.4 jsonschema-specifications 2023.7.1 keras 2.12.0 kiwisolver 1.4.4 langchain 0.0.142 lazy_loader 0.3 libclang 16.0.6 lightning-utilities 0.9.0 linkify-it-py 2.0.2 llama-index 0.5.27 llvmlite 0.40.1 lmdb 1.3.0 lz4 4.3.2 Markdown 3.4.3 markdown-it-py 2.2.0 MarkupSafe 2.1.3 marshmallow 3.20.1 matplotlib 3.7.2 mdit-py-plugins 0.3.3 mdurl 0.1.2 ml-dtypes 0.2.0 monotonic 1.6 more-itertools 10.1.0 mpmath 1.3.0 multidict 6.0.4 mypy-extensions 1.0.0 mysqlclient 2.2.0 networkx 3.1 numba 0.57.1 numexpr 2.8.4 numpy 1.23.5 oauthlib 3.2.2 omegaconf 2.2.3 onnx 1.14.0 onnxruntime 1.15.1 onnxruntime-gpu 1.15.0 openai 0.27.8 openai-whisper 20230918 openapi-schema-pydantic 1.2.4 opencv-contrib-python 4.8.0.74 opencv-python-headless 4.8.0.74 opennsfw2 0.10.2 opentelemetry-api 1.19.0 opentelemetry-exporter-otlp 1.19.0 opentelemetry-exporter-otlp-proto-common 1.19.0 opentelemetry-exporter-otlp-proto-grpc 1.19.0 opentelemetry-exporter-otlp-proto-http 1.19.0 opentelemetry-exporter-prometheus 1.12.0rc1 opentelemetry-instrumentation 0.40b0 opentelemetry-instrumentation-aiohttp-client 0.40b0 opentelemetry-instrumentation-asgi 0.40b0 opentelemetry-instrumentation-fastapi 0.40b0 opentelemetry-instrumentation-grpc 0.40b0 opentelemetry-proto 1.19.0 opentelemetry-sdk 1.19.0 opentelemetry-semantic-conventions 0.40b0 opentelemetry-util-http 0.40b0 opt-einsum 3.3.0 orjson 3.9.2 overrides 7.3.1 packaging 23.1 pandas 2.0.3 pathspec 0.11.2 Pillow 9.2.0 pip 23.2.1 platformdirs 3.9.1 posthog 3.0.1 prettytable 3.8.0 prometheus-client 0.17.1 psutil 5.9.5 pulsar-client 3.2.0 pyasn1 0.5.0 pyasn1-modules 0.3.0 pycparser 2.21 pydantic 1.10.12 pydantic_core 2.10.1 pydub 0.25.1 pygit2 1.12.2 Pygments 2.16.1 Pympler 1.0.1 pyparsing 3.0.9 pypdf 3.15.0 PyPika 0.48.9 pyreadline3 3.4.1 PySocks 1.7.1 python-dateutil 2.8.2 python-dotenv 1.0.0 python-engineio 4.5.1 python-multipart 0.0.6 python-socketio 5.8.0 pytorch-lightning 1.9.4 pytz 2023.3 PyWavelets 1.4.1 pywin32 306 PyYAML 6.0 qudida 0.0.4 referencing 0.30.0 regex 2023.6.3 requests 2.31.0 requests-oauthlib 1.3.1 rpds-py 0.9.2 rsa 4.9 safetensors 0.3.1 scikit-image 0.21.0 scikit-learn 1.3.0 scipy 1.9.3 semantic-version 2.10.0 semver 3.0.1 setuptools 68.0.0 six 1.16.0 smmap 5.0.0 sniffio 1.3.0 soupsieve 2.4.1 SQLAlchemy 2.0.21 starlette 0.27.0 sympy 1.12 tb-nightly 2.14.0a20230718 tenacity 8.2.2 tensorboard 2.12.3 tensorboard-data-server 0.7.1 tensorflow 2.12.0 tensorflow-estimator 2.12.0 tensorflow-intel 2.12.0 tensorflow-io-gcs-filesystem 0.31.0 termcolor 2.3.0 threadpoolctl 3.2.0 tifffile 2023.7.10 tiktoken 0.3.3 timm 0.9.5 tk 0.1.0 tokenizers 0.13.3 toml 0.10.2 tomli 2.0.1 toolz 0.12.0 torch 2.0.1+cu118 torchmetrics 1.2.0 torchsde 0.2.5 torchvision 0.15.2+cu118 tornado 6.3.3 tqdm 4.64.1 trampoline 0.1.2 transformers 4.30.2 typing_extensions 4.7.1 typing-inspect 0.9.0 tzdata 2023.3 tzlocal 5.0.1 uc-micro-py 1.0.2 urllib3 1.26.16 uvicorn 0.23.2 validators 0.21.2 watchdog 3.0.0 watchfiles 0.19.0 wcwidth 0.2.6 websocket-client 1.6.2 websockets 11.0.3 Werkzeug 2.3.6 wheel 0.40.0 wrapt 1.14.1 xformers 0.0.22 yapf 0.40.1 yarl 1.9.2 you-get 0.4.1650 zipp 3.16.2 zstandard 0.21.0
Yes! The pydantic version should be 2.x, it's dependent on latest fastapi version.
I see a lot of packages. May be you should use miniconda to create a new enviroment.
Thank you, reinstalling the environment solved it.
The error is as follows: INFO: Started server process [15148] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:8888 (Press CTRL+C to quit) INFO: 127.0.0.1:8563 - "GET / HTTP/1.1" 404 Not Found INFO: 127.0.0.1:8563 - "GET / HTTP/1.1" 404 Not Found