gradio icon indicating copy to clipboard operation
gradio copied to clipboard

Gradio apps are not displaying properly in Google Colab notebooks (ipynb files)

Open rajayourfriend opened this issue 1 year ago • 4 comments

Describe the bug

In Google Colab notebook, below is the sequence of code (very basic python application) of gradio is checked if it works !

import gradio as gr
def update(name):
    return f"Welcome to Gradio, {name}!"

with gr.Blocks() as demo:
    gr.Markdown("Start typing below and then click **Run** to see the output.")
    with gr.Row():
        inp = gr.Textbox(placeholder="What is your name?")
        out = gr.Textbox()
    btn = gr.Button("Run")
    btn.click(fn=update, inputs=inp, outputs=out)

demo.launch()

Prior to this the installation of gradio is done by below code : %pip install gradio

Have you searched existing issues? 🔎

  • [X] I have searched and found no existing issues

Reproduction

import gradio as gr

Screenshot

image Screenshot 2024-04-28_ForGradioBug

Logs

/usr/local/lib/python3.10/dist-packages/gradio/routes.py:1097: DeprecationWarning: 
        on_event is deprecated, use lifespan event handlers instead.

        Read more about it in the
        [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
        
  @app.on_event("startup")
/usr/local/lib/python3.10/dist-packages/fastapi/applications.py:4495: DeprecationWarning: 
        on_event is deprecated, use lifespan event handlers instead.

        Read more about it in the
        [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
        
  return self.router.on_event(event_type)
/usr/local/lib/python3.10/dist-packages/gradio/analytics.py:99: UserWarning: unable to parse version details from package URL.
  warnings.warn("unable to parse version details from package URL.")
Setting queue=True in a Colab notebook requires sharing enabled. Setting `share=True` (you can turn this off by setting `share=False` in `launch()` explicitly).

Colab notebook detected. To show errors in colab notebook, set debug=True in launch()

Could not create share link. Missing file: /usr/local/lib/python3.10/dist-packages/gradio/frpc_linux_amd64_v0.2. 

Please check your internet connection. This can happen if your antivirus software blocks the download of this file. You can install manually by following these steps: 

1. Download this file: https://cdn-media.huggingface.co/frpc-gradio-0.2/frpc_linux_amd64
2. Rename the downloaded file to: frpc_linux_amd64_v0.2
3. Move the file to this location: /usr/local/lib/python3.10/dist-packages/gradio
Running on https://localhost:7860/

System Info

In Google Colab notebook (ipynb file), above experiment is done.

Severity

Blocking usage of gradio

rajayourfriend avatar Apr 28 '24 17:04 rajayourfriend

I have the same issue even when placing the requested file in the directory. https://github.com/lllyasviel/Fooocus/issues/2817 this solution was mentioned in another repo

omprakashnarayan avatar Apr 28 '24 18:04 omprakashnarayan

Thanks Om for the response. But I could not understand, how that other bug 2817 is related to the present problem here. Could you please tell me, about specific points towards fix / workaround ?

For example take the hello world application :

import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
    
if __name__ == "__main__":
    demo.launch() 

This does not work properly in Google colab's ipynb Notebook. This is the problem I am facing.

rajayourfriend avatar Apr 28 '24 18:04 rajayourfriend

Sorry for my hurry ! When I read through completely, got below as the workaround.

!wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
!dpkg -i cloudflared-linux-amd64.deb

I tested and found to be working good !

Thanks a lot @omprakashnarayan

rajayourfriend avatar Apr 28 '24 18:04 rajayourfriend

Even though above two commands of wget and dpkg are run, I get the problematic way of display as given in the beginning of this bug. Can you please suggest any solution for this please please please

rajayourfriend avatar Apr 30 '24 16:04 rajayourfriend