I have a repo created in GitHub already, with some folders, in one of these is my .py, the one is executing by streamlit.
Now, I tried to deploy the app and everything is good till, show up this error.
2023-02-15 12:56:59.338 Uncaught app exception
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.__dict__)
File "/app/startup-predictions/streamlit/proyecto.py", line 15, in <module>
with open('model_miguel_recall.pkl', 'rb') as re:
FileNotFoundError: [Errno 2] No such file or directory: 'model_miguel_recall.pkl'
when I tried on my host, it work properly, cause this pkl is in the same path of .py, so the path has been written correctly.
I opened in my local host correctly, but when I use my own link from streamlit I have gotten this error:
File "/home/appuser/venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.__dict__)
File "/app/startup-predictions/streamlit/proyecto.py", line 28, in <module>
img = Image.open('streamlit/introfoto.jpeg')
File "/home/appuser/venv/lib/python3.10/site-packages/PIL/Image.py", line 3227, in open
fp = builtins.open(filename, "rb")
But I reorganized the folder, to get not messy. This is my repo:
Because the working directory is different. In the deployment environment the working directory is the root of the repository /app/startup-predictions so the relative path to the pickled model is streamlit/model/model_miguel_recall.pkl.
The working directory is usually where the python interpreter is launched.