Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradio Interface does not run locally without internet connection #1450

Open
1 task done
liuyixi520 opened this issue Jun 2, 2022 · 23 comments
Open
1 task done

Gradio Interface does not run locally without internet connection #1450

liuyixi520 opened this issue Jun 2, 2022 · 23 comments
Labels
bug Something isn't working
Milestone

Comments

@liuyixi520
Copy link

Describe the bug

I am in a offline environment, that can not connect the internet.
I see nothing in my browser when following 'Quick Start' section of the readme.

  1. use conda Create environment with python 3.7: conda create -n gradio3 python=3.7
  2. install gradio: pip install gradio
    Run the example script
    In the browser (Chrome and Edge tested) I see nothing. There errors in the console logs that say:
    https://fonts.googleapis.com/css?family=Source Sans Pro net::ERR_NAME_NOT_RESOLVED

can anyone give me a hlep to slove this problem, thanks very much. I am in a hurry

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

import gradio as gr

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

gr.Interface(fn=greet, inputs="text", outputs="text").launch(debug=True)

Screenshot

2125392789

Logs

Running on local URL:  http://127.0.0.1:7860/

To create a public link, set `share=True` in `launch()`.

System Info

Gradio: 3.0.10
Python: 3.7.0
OS: Windows 7
Browsers: Chrome 70.0.3538.110

Severity

blocking all usage of gradio

@liuyixi520 liuyixi520 added the bug Something isn't working label Jun 2, 2022
@abidlabs
Copy link
Member

abidlabs commented Jun 2, 2022

Hmmm it looks like we are loading certain assets from the web for Gradio 3.0. We should fix that @aliabid94

In the meantime, perhaps you can try using an older version of gradio (say gradio==2.9.4 -- I don't think they require being online)

@liuyixi520
Copy link
Author

Hmmm it looks like we are loading certain assets from the web for Gradio 3.0. We should fix that @aliabid94

In the meantime, perhaps you can try using an older version of gradio (say gradio==2.9.4 -- I don't think they require being online)

thank you very much, my problem has been solved by your advice.
and when you fix this bug in your new version, can you give me a message, so i can use gradio3 in my work

@abidlabs abidlabs added this to the 3.1 milestone Jun 7, 2022
@abidlabs abidlabs changed the title net::ERR_NAME_NOT_RESOLVED Gradio Interface does not run locally without internet connection Jun 7, 2022
@aliabid94
Copy link
Collaborator

That's strange. Will take a look.

@abidlabs
Copy link
Member

abidlabs commented Jul 6, 2022

Related to fonts: #1224

@pngwn pngwn removed this from the 3.1 milestone Jul 11, 2022
@abidlabs abidlabs added this to the 3.2 milestone Aug 1, 2022
@pngwn
Copy link
Member

pngwn commented Aug 11, 2022

We currently load fonts from the google fonts CDN, the iframe resizer from CDNJS and bokeh from the Bokeh CDN. All of these things will break when offline. We need to copy the source and self host, preferably along with other static assets on the CDN rather than on the server in order to fix these issues (we should be self hosting fonts for performance reasons but font are slightly more complex as the google CDN is quite clever, we need to ensure we only load the smallest subset we can get away with).

@pngwn pngwn removed their assignment Aug 11, 2022
@abidlabs abidlabs modified the milestones: 3.2, 3.x Aug 18, 2022
@tpanza
Copy link

tpanza commented Sep 3, 2022

What help is needed with this?

Besides fonts, there are several places in the code where contact via https is attempted to gradio.app.

$ grep -RnF 'gradio.app'
documentation.py:18:    documentation at www.gradio.app/docs.
networking.py:29:GRADIO_API_SERVER = "https://api.gradio.app/v1/tunnel-request"
strings.py:5:MESSAGING_API_ENDPOINT = "https://api.gradio.app/gradio-messaging/en"
utils.py:46:analytics_url = "https://api.gradio.app/"
utils.py:47:PKG_VERSION_URL = "https://api.gradio.app/pkg-version"
templates/cdn/index.html:11:            <meta property="og:url" content="https://gradio.app/" />
templates/cdn/assets/index.8da6a09f.js:6197:                    attr(a, "href", "https://gradio.app");
templates/frontend/index.html:11:               <meta property="og:url" content="https://gradio.app/" />
templates/frontend/share.html:11:               <meta property="og:url" content="https://gradio.app/" />
templates/frontend/assets/index.4ddf74a5.js:6197:                       attr(a, "href", "https://gradio.app");

This also breaks when offline, with the exception of MESSAGING_API_ENDPOINT, which has a fallback provision to use hardcoded defaults.

@bolshoytoster
Copy link

Another thing to note, analytics are on by default, which don't work with no network.

If anyone else is having issues with this, you can add analytics_enabled=False when initialising your gr.Interface/gr.TabbedInterface.

@ThatCoffeeGuy
Copy link

Another thing to note, analytics are on by default, which don't work with no network.

If anyone else is having issues with this, you can add analytics_enabled=False when initialising your gr.Interface/gr.TabbedInterface.

Do we know what sort of data is being mined by analytics?

@abidlabs
Copy link
Member

abidlabs commented Apr 5, 2023

See here:

data = {

and here:

data = {

@Juenjie
Copy link

Juenjie commented Apr 11, 2023

@abidlabs I want to deploy a chatbot on my local machine without internet connection for many users. However, when I use gradio==2.9.4, it does not contain the class gr.chatbot. When I use 3.24.1, it requires internet connection. Do you have any suggestion on this? I am not familiar with UI.

@abidlabs
Copy link
Member

Hi @Juenjie unfortunately I do not think it is possible to use gr.Chatbot right now without Internet connection. The gr.Chatbot component was introduced in 3.x and, as you mentioned, 3.x currently does require Internet connection, mostly to fetch frontend assets.

@OgalFinklestein
Copy link

Happy Bugiversary. Are the plans to resolve this year-old issue?

@aliabid94
Copy link
Collaborator

#4398 should fix offline for most use cases

@pourmand1376
Copy link

pourmand1376 commented Jul 31, 2023

My Gradio app want to load some javascript file from Amazon which it fails on my server (my server and my client don't have access to the internet). What should I do?

Url of the file: https://gradio.s3-us-west-2.amazonaws.com/3.39.0/assets/index-fda37c89.js.

Is there any way to make this file available offline?

@pourmand1376
Copy link

Update: I've found mutliple places where amazonaws is used (+).

<script
type="module"
src="https://gradio.s3-us-west-2.amazonaws.com/{version}/gradio.js"
></script>
</svelte:head>

@markdjwilliams
Copy link

I'm encountering this exact issue in gradio 3.44.4

Is there an earlier 3.x version which supports offline usage?

@pngwn
Copy link
Member

pngwn commented Sep 20, 2023

Do you have an example app showing this behaviour? The CDN should only be used when embedding gradio apps, for local apps it should be pulling the files from your local file system.

@pngwn
Copy link
Member

pngwn commented Sep 20, 2023

Update: I've found mutliple places where amazonaws is used

This is just the Gradio website and doesn't affect the Gradio library.

@xinqingguo
Copy link

analytics_enabled=False

This works! My Gradio version is 4.19.2

@djaym7
Copy link

djaym7 commented Apr 2, 2024

@xinqingguo did you set the env variable os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
or some parameter ?

@justinzyw
Copy link

We currently load fonts from the google fonts CDN, the iframe resizer from CDNJS and bokeh from the Bokeh CDN. All of these things will break when offline. We need to copy the source and self host, preferably along with other static assets on the CDN rather than on the server in order to fix these issues (we should be self hosting fonts for performance reasons but font are slightly more complex as the google CDN is quite clever, we need to ensure we only load the smallest subset we can get away with).

Same here. the fonts loading from the google fonts and the iframe resizer loading from cloudflare are the blockers.

@abidlabs abidlabs modified the milestones: 4.x, Gradio 5️⃣ Jul 2, 2024
@abidlabs
Copy link
Member

abidlabs commented Jul 2, 2024

This could be good for 5.0 @aliabid94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests