FileNotFoundError: This app has encountered an error

I’m trying to deploy this app at streamlit. It works fine on localhost but encounters errors at the time of deployment. Usually when I upload file, it throws error.

FileNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).


File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/", line 556, in _run_script
    exec(code, module.__dict__)
File "/app/shop-analysis/", line 42, in <module>
    df = get_data_from_excel()
File "/app/shop-analysis/", line 24, in get_data_from_excel
    df = pd.read_excel(
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/util/", line 311, in wrapper
    return func(*args, **kwargs)
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/excel/", line 457, in read_excel
    io = ExcelFile(io, storage_options=storage_options, engine=engine)
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/excel/", line 1419, in __init__
    self._reader = self._engines[engine](self._io, storage_options=storage_options)
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/excel/", line 525, in __init__
    super().__init__(filepath_or_buffer, storage_options=storage_options)
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/excel/", line 508, in __init__
    self.handles = get_handle(
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/", line 795, in get_handle
    handle = open(handle, ioargs.mode)

Thanks in advance :grin:

The file uploader widget just stores the file in memory, so it won’t help to just give pandas the name of that file. You will need to pass the BytesIO data to it:

Try this:

uploaded_file = st.file_uploader(
    "Choose your database", accept_multiple_files=False)
if uploaded_file is not None:
    file_name = uploaded_file
    file_name = "DatabaseSample.xlsx"

This way, you either pass the name of the file you have pre-saved or you pass the BytesIO data of something new from the user.


Thanks buddy, it works :confetti_ball:
Can you tell me how you got the idea to fix this error?

Just from the documentation. Every single function in every single library has specific requirements about data types it accepts and returns. Python lets us be a little hand-wavy about it, but for all coding you always want to have a firm grasp of what each object’s data type is. :slight_smile:

1 Like

Thanks for the help :+1:

Where can i try this code?

I don’t have that particular snippet hosted anywhere, so you can copy it into your own file to work with. Feel free to post a question if you are having some difficulty using it.

A post was split to a new topic: Help with JSONDecodeError