FileNotFound Error When Deploying to streamlit

  1. The app

  2. The Github

  3. Full Error Message:

Traceback (most recent call last):
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/script_runner.py”, line 354, in _run_script
exec(code, module.dict)
File “/mount/src/my-data-projects/World-Universities-EDA/app.py”, line 18, in
world_uni_df = pd.read_csv(file_path, encoding=‘latin1’)
File “/home/adminuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py”, line 1024, in read_csv
return _read(filepath_or_buffer, kwds)
File “/home/adminuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py”, line 618, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File “/home/adminuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py”, line 1618, in init
self._engine = self._make_engine(f, self.engine)
File “/home/adminuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py”, line 1878, in _make_engine
self.handles = get_handle(
File “/home/adminuser/venv/lib/python3.9/site-packages/pandas/io/common.py”, line 873, in get_handle
handle = open(
FileNotFoundError: [Errno 2] No such file or directory: ‘./world-uni-rankings.csv’

  1. Streamlit version: 0.88.0 and python version: 3.11

I’m having trouble deploying my app because streamlit failed to find my file “world-uni-rankings.csv”. I don’t understand why I’m getting the error since all my files are in the same directory, and I also used relative pathing pointing to the current directory. Does anyone have any idea how to resolve this issue?

Would appreciate some advice :pray:!

Does this app work locally?
Have you tried using the latest streamlit version?

1 Like

Hi Ferdy!

  1. Yes the app does work perfectly fine locally
  2. I have tried using the latest streamlit version after reading your suggestion (streamlit 1.3.0) but it’s still not able to find my file.

Hi,

I’ve managed to find a workaround by providing the raw github file path as follows:

file_path = 'https://raw.githubusercontent.com/Qamil-Mirza/My-Data-Projects/main/World-Universities-EDA/world-uni-rankings.csv'
world_uni_df = pd.read_csv(file_path, encoding='latin1')

This finally allowed streamlit to have access to the file!

I forked your repo and successfully deployed in SCC. I made some changes like moving the files outside, and use latest library version. I usually deploy like this to not mess with the file system. The repo name is the working directory.

Also you don’t need numpy and pandas in the requirements.txt, it is already included in streamlit.

I also thought about taking the file like this:

file_path = './World-Universities-EDA/world-uni-rankings.csv'

Considering that your repo is the current working directory and streamlit runs the app with:

./World-Universities-EDA/app.py
1 Like

Hi! I see, that’s really interesting. I’ll look into it. Also, thank you for the additional info on Streamlit having the numpy and Pandas Dependencies!

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