I am running a project cloned from GitHub. The project code tries to execute a function when clicking the Gradio button, but the function is not executed when it is actually run. After multiple troubleshooting, I tried to copy a demo code from the Gradio official website to run it, the code similar to the following. When I ran it, I found that the function was not executed and there was no output in the console. I tried to upgrade/downgrade my Gradio version, but the result was the same. This looks like a bug. What should I do to make this function execute correctly?
code:
import gradio as gr
def greet(name):
print("1111111111111")
return "Hello " + name + "!"
with gr.Blocks() as demo:
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
demo.launch()
Have you searched existing issues? 🔎
[X] I have searched and found no existing issues
Reproduction
import gradio as gr
def greet(name):
print("1111111111111")
return "Hello " + name + "!"
with gr.Blocks() as demo:
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
demo.launch()
Screenshot
No response
Logs
(dust3r) hygx@DESKTOP-KJL14T8:~/code/dust3r$ python3 test.py
* Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
System Info
Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 5.0.0b10
gradio_client version: 1.4.0b5
------------------------------------------------
gradio dependencies in your environment:
aiofiles: 23.2.1
anyio: 4.6.0
fastapi: 0.115.0
ffmpy: 0.4.0
gradio-client==1.4.0-beta.5 is not installed.
httpx: 0.27.2
huggingface-hub: 0.25.2
jinja2: 3.1.4
markupsafe: 2.1.3
numpy: 1.26.4
orjson: 3.10.7
packaging: 24.1
pandas: 2.2.3
pillow: 10.4.0
pydantic: 2.9.2
pydub: 0.25.1
python-multipart: 0.0.12
pyyaml: 6.0.1
ruff: 0.6.9
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.5
typing-extensions: 4.11.0
urllib3: 2.2.3
uvicorn: 0.31.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.
gradio_client dependencies in your environment:
fsspec: 2024.9.0
httpx: 0.27.2
huggingface-hub: 0.25.2
packaging: 24.1
typing-extensions: 4.11.0
websockets: 11.0.3
Describe the bug
I am running a project cloned from GitHub. The project code tries to execute a function when clicking the Gradio button, but the function is not executed when it is actually run. After multiple troubleshooting, I tried to copy a demo code from the Gradio official website to run it, the code similar to the following. When I ran it, I found that the function was not executed and there was no output in the console. I tried to upgrade/downgrade my Gradio version, but the result was the same. This looks like a bug. What should I do to make this function execute correctly?
code:
Have you searched existing issues? 🔎
Reproduction
Screenshot
No response
Logs
System Info
Severity
Blocking usage of gradio