I'm following the basic Gradio interface from the Gradio documentation:
import gradio as gr
def greet(name):
return "Hello " + name #+ "!" +a
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()
When I go to the UI via Chrome (http://127.0.0.1:7860/), whenever I submit the first query right after stating the server, I always get an "error":
The error message is:
Traceback (most recent call last):
File "C:\Users\fra\anaconda3\envs\project\lib\site-packages\gradio\routes.py", line 534, in predict
output = await route_utils.call_process_api(
File "C:\Users\fra\anaconda3\envs\project\lib\site-packages\gradio\route_utils.py", line 226, in call_process_api
output = await app.get_blocks().process_api(
File "C:\Users\fra\anaconda3\envs\project\lib\site-packages\gradio\utils.py", line 855, in __exit__
matplotlib.use(self._original_backend)
File "C:\Users\fra\anaconda3\envs\project\lib\site-packages\matplotlib\__init__.py", line 1276, in use
plt.switch_backend(name)
File "C:\Users\fra\anaconda3\envs\project\lib\site-packages\matplotlib\pyplot.py", line 343, in switch_backend
canvas_class = module.FigureCanvas
AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'
However, subsequent queries work fine:
Why does the first query error while subsequent queries work fine? I use Windows 10.
Created a new env in anaconda, installed
python 3.8.18
, it worked for me