"Please wait..." forever when accessing through Network URL

I have tried everything on the https://docs.streamlit.io/en/0.62.0/troubleshooting/not-loading.html

None of the two solutions works. When I host the app, the prompt is fine. But when I then try to access the app via either the network url or the local, it suddenly keeps spamming the messages in the picture below every millisecond and the app just says “Please Wait…” and blinks “Connecting…” in the upper right corner… Any hints?
Streamlit version: 0.69.2

Hi @Prelon -

From the error message, it seems like the issue is that it can’t find the file on the G:// drive. If you’re hosting this app somewhere other than the computer where you developed it, it’s unlikely that the same drive letter will be applicable.

It’s better if you can either give an exact directory path including the machine name, or using a relative reference to the file relative to where the Python code is running.

Best,
Randy

Hi @randyzwitch,

Well that is the odd thing. I don’t think the drive where the file is located on is the problem.
It does it even though I am on my C:// drive as well.

Right, but if Python is throwing an error, then it doesn’t really matter the drive letter.

To debug, can you comment out the section that contains the file reading portion and see if the app loads? If it does, then we can focus on fixing that error. Or, feel free to post a code snippet and I can try it myself.

I have found the issue but I have absolutely no idea why it is causing it…
When I comment out snippet 1, it works. Yet, snippet 2 is causing no problems…
Could it be due to the sheer size of the FastText-model (128MB)?

Note: I’ve tried with and without @st.cache(allow_output_mutation=True).

SNIPPET 1

@st.cache(allow_output_mutation=True)
def load_fasttext():
classifier = fasttext.load_model(r"C:/Repos/Streamlit/Baggrundstjek/fasttext.bin")
return classifier
classifier = load_fasttext()

SNIPPET 2

@st.cache(allow_output_mutation=True)
def load_pep():
data = pd.read_excel(r’file:///C:/Repos/Streamlit/Baggrundstjek/PEP_listen_updated 09102020.xlsx’)
data = data[data[‘Fornavn’].notna()]
return data
pep = load_pep()

What is even more odd is that everything works perfectly fine every single time if i do the following…

Step 1:
Run the streamlit x.py file.
Step 2:
go to the app (either through localhost or network url, doesn’t matter)
Step 3: Experiencing the " Symptom #2: The app says “Please wait…” forever" (https://docs.streamlit.io/en/0.62.0/troubleshooting/not-loading.html)
Step 3: Shut down the app in the anaconda prompt and start it again immediately while remaining on the app in the browser.
Step 4: The app instanly “gets connection” and loads and works perfectly fine…

However, this is not a solution since I can’t restart the app everytime someone tries to access it.
I am quite sure the problem is somehow related to when I load a file in the script, but why?

My colleague is experiencing the exact same issue. Can this be related to our infrastructure?

I am 99% that I have identified what’s causing the issue although I am not able to explain it…

The problem was “os.chdir(“some_path”)”… If I outcomment that, it consistently works fine so far.

Is that a general thing, @randyzwitch? To not use os.chdir()?

No, this (almost certainly) isn’t a Streamlit-related issue. Running chdir() seems like the wrong method to be using in an application. Can you specify the directory path explicitly, or at least make a relative reference to the file?