FileNotFound error on deployment

I’m attempting to deploy my data app to streamlit cloud but it keeps giving me this message:

After building it and testing it on localhost, everything works fine until I try uploading it. In my GitHub repository I’ve also included all the dependencies in the ‘requirements.txt’, which includes openpyxl.

Some steps I took to try to resolve the issue, here is my old code:

fl = st.file_uploader(":file_folder: Upload a file", type=(["csv", "txt", "xlsx", "xls"]))
if fl is not None:
    filename = fl.name
    st.write(filename)
    df = pd.read_excel(fl)
else:
    ss = r"C:\Users\ZION\Downloads\Sample - Superstore(new).xlsx"
    df = pd.read_excel(r"C:\Users\ZION\Downloads\Sample - Superstore(new).xlsx")

Here is my new code, which I changed to pass the file to 'pd.read_excel() ’ and save the uploaded file using ‘with open()’. But the issue still persists.

if fl is not None:
    with open(fl.name, "wb") as f:
        f.write(fl.getbuffer())

    df = pd.read_excel(fl.name)
else:
    ss = r"C:\Users\ZION\Downloads\Sample - Superstore(new).xlsx"
    df = pd.read_excel(ss)

Also to mention, I imported os to check the file’s existence in a separate .ipynb, and it comes back True. I don’t know if I have to do anything else with os or what. But aforesaid, the web app deploys locally and works fine.
If any one knows anything about this issue, if i’m missing something or should do something differently, please let me know. Thanks.

When you host your repo on streamlit cloud, do you include the excel files in the same folder? Because the file not found error means it cant access those files which it could locally.

1 Like

You don’t have access to your local computers hardware if your streamlit app runs on any hosted environment.

1 Like

Ha! I overlooked something so simple. Thanks

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.