FileNotFoundError pickle file

My project here works perfectly locall under a virtual environment with python 3.8.
But when I upload it here it says
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.
File “/app/rakuteam/Streamlit_rakuten/”, line 28, in load_keywords_fromfile
with open(‘dico_keywords_tfidf_15.pkl’, ‘rb’) as handle:

How Can I check if my file’dico_keywords_tfidf_15.pkl’ was correctly uploaded? Is it a problem with pickle (but I don’t have any issue locally …)

Did you upload dico_keywords_tfidf_15.pkl in your github repo?

If you use with open(‘dico_keywords_tfidf_15.pkl’, ‘rb’) as handle:, then dico_keywords_tfidf_15.pkl should be in the relative path of where is.
Please share the repo if you still struggle.

The app is [] and the .pkl is in the same directory

Could anyone help on this please? Thanks

1 Like

Hi @Dam1006, :wave:

Welcome to the community! :partying_face:

  1. Change the filepath to the pickle file on line 28 of to:
with open('Streamlit_rakuten/dico_keywords_tfidf_15.pkl', 'rb') as handle: 
  1. Also, replace opencv-python== with opencv-python-headless== to avoid:

    ImportError: cannot open shared object file: No such file or directory
  2. Go through all your Python scripts and make sure to prepend Streamlit_rakuten/ to the paths of any files you open in them and just ensure you have the correct filepaths. e.g. Cnnimage_predict("Streamlit_rakuten/test2.jpg")

Best, :balloon:

Thanks Snehan! It s much better but I have another issue how do I manage a file which is managed by GIT LFS (because it s 225Mo) ?

Hello, I was having a similar deploying a Streamlit app. At first it was issues with requirements files for cv2, but I think that is sorted, but now I am getting this error:

ModuleNotFoundError: 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.


File “/home/appuser/venv/lib/python3.7/site-packages/streamlit/”, line 354, in _run_script
exec(code, module.dict)File “/app/smile_project/”, line 56, in
CNN_model = pickle.load(pickle_file)

For some context, I have a Keras object class ‘keras.engine.sequential.Sequential’ which I have created as a .pkl file and have it in the same directory as my python files. It works locally when I run the program, but does not work at deployment time. Leading up to this step there were also errors saying that I was missing Keras and tensor flow, which I added into my requirments.txt file.

I also did some snooping around Streamlit other Streamlit forums and found that sometimes the pickle error can occur when the model that you pickled was exported when using a different version of python than the one being used in Streamlit. I checked this, and this was the case, so I took the model out of google Colab, I trained it in Atom on my local python environment which is running python 3.7 and pickled it from there, and I still got the same error, when trying to deploy it on Streamlit. It works locally still but is still giving the same error.

File “/app/smile_project/”, line 47, in
with open(“CNN_Model_p7.pkl”, “rb”) as pickle_file:

Here are my requirments.txt files:


Here are my packages.txt files:

Here is my repo

Thanks in advance!

  • Paul