FileNotFoundError: [Errno 2] No such file or directory:

hi. I tried to deploy a streamlit app to render, but I got the following error:

FileNotFoundError: [Errno 2] No such file or directory: 'images/icon.png'

Traceback:
File "/opt/render/project/src/.venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)File "/opt/render/project/src/brookfield.py", line 149, in <module>
    main()File "/opt/render/project/src/brookfield.py", line 26, in main
    icon = Image.open('images/icon.png')File "/opt/render/project/src/.venv/lib/python3.9/site-packages/PIL/Image.py", line 3236, in open
    fp = builtins.open(filename, "rb")

I’m pretty sure that there is a file named icon.png in a folder called images in the same directory as the .py file. The web app runs perfectly locally until it is deployed to render. What could be wrong, and how do I solve this issue, please?

Hi,

A common issue, when the path seems correct, can be file-casing.

Render uses Linux, which has a case-sensitive filesystem. Ensure the referenced filepath in your code is the same as it appears in your git repo. e.g. images/icon.png would be different to images/Icon.png

Alan

Thank you very much. it is actually image/icon.PNG not images/icon.png
Cheers…

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