FileNotFoundError: [Errno 2] No such file or directory

Hi, this is Rick. I have been spending a whole day dealing with this problem. When I added my app to the cloud, it cannot find the image. I used the relative path to locate the image and this method worked well in my local computer. But when I move to the cloud, the error occurred. That’s strange. I guess the error is about the path but I cannot find a workable solution.
My code is attached: GitHub - RickLin616/3170


The local app looks like this.

While on the cloud, I got an error.

You need to use forward slashes and not backslashes. A local Windows environment will happily accept either, but Streamlit Cloud is a Debian container.

1 Like

File “/home/appuser/venv/lib/python3.9/site-packages/joblib/numpy_pickle.py”, line 650, in load
with open(filename, ‘rb’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘C:/Users/User/Desktop/Dataset Trials/ML/model_joblib_gr’.

This is the error I am getting, I have used forward slashes but still.

If you have deployed to Community Cloud, you will need to make sure any reference files are also in your repository (and referenced with relative paths) or hosted somewhere else that can be reached by a URL. If you are using a file saved to your local computer’s C drive, a deployed app will not have access to that file.

Hey @RickLin ,

I would also advise that you try exploring cloud-based solutions for your file issue.

If you absolutely NEED your program to access a file, host it on a cloud platform such as a Cloud Bucket or even Snowflake’s Database.

This way, if your data is structure OR unstructured, you can get access to it in a few lines of code.

Let me know if you’ve tried this approach- it should definitely help solve your issue!