How to solve this problem? I can't implement gradio

ImportError Traceback (most recent call last)
in <cell line: 3>()
1 from langchain.chat_models import ChatOpenAI
2 from langchain.schema import AIMessage, HumanMessage, SystemMessage
----> 3 import gradio as gr
4
5 def response(message, chat_history):

13 frames
/usr/local/lib/python3.10/dist-packages/fastapi/exceptions.py in
4 from starlette.exceptions import HTTPException as StarletteHTTPException
5 from starlette.exceptions import WebSocketException as StarletteWebSocketException
----> 6 from typing_extensions import Annotated, Doc # type: ignore [attr-defined]
7
8

ImportError: cannot import name ‘Doc’ from ‘typing_extensions’ (/usr/local/lib/python3.10/dist-packages/typing_extensions.py)

I had the same issue in Colab. My code is as follows

!pip install -q gradio
import gradio

I try to run the same code in Kaggle. There are some Warning messages:
“ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts…”
I modified my code:

!pip install -q gradio --use-deprecated=legacy-resolver

Everything is fine.

Oh! I got a solution from CSDN. It can fix the above error in Colab. Try to install gradio with the version of 3.45.0.

!pip install -q gradio==3.45.0
1 Like