- My app won’t open. Source: https://share.streamlit.io/steveschneider2/pass/main/TrafficStreamlitApp.py The app (python) needs to load a “pickle” file (which is a ML Model). I have t his app running well on my machine. Today was the first time i have connected to the streamlit cloud. The pickle file is in the same folder as the python file, and is in the Github repo from which the app loaded. So, if the pickle file was loaded (as just one of the files in the repo) ‘up’ to streamlit why can it not be located? Should i be changing the load line somehow? Below is that line: xgb1 = pickle.load(open(‘FloridaTraffic2014xgb.pkl’, ‘rb’)) Any help is appreciated. If i am asking this question in the wrong place, please re-direct me. Thanks! also, here’s the error msg: File “/app/pass/TrafficStreamlitApp.py”, line 57, in xgb1 = pickle.load(open(‘FloridaTraffic2014xgb.pkl’, ‘rb’)) (edited)
Hi @steve_Schneider , welcome to the Streamlit community!
Can you post more of the error message, it’s not clear what the issue might be. You could also try setting the Python version on Streamlit Cloud; pickle requires that you use the same Python version to read the pickle as was used to write it:
randy, first, thank you for your response. Second, i deleted the app, reloaded, specifying Python 3.8. Here is the key part of the messaging…
[manager] Starting up for owner: 'steveschneider2', repository: 'pass', branch: 'main', main module: 'TrafficStreamlitApp.py'
[manager] Cloning repository ...
[manager] Cloning into 'pass'...
[manager] Cloned repository!
[manager] Processing dependencies ...
[manager] Processed dependencies!
2021-10-11 18:26:11.459 Uncaught app exception
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.8/site-packages/streamlit/script_runner.py", line 354, in _run_script
File "/app/pass/TrafficStreamlitApp.py", line 57, in <module>
xgb1 = pickle.load(open('FloridaTraffic2014xgb.pkl', 'rb'))
ModuleNotFoundError: No module named 'xgboost'
ModuleNotFoundError: No module named ‘xgboost’
So it looks like the issue isn’t actually the pickle, but that you are missing a dependency in your requirements file. Which in your case doesn’t actually exist.
Create a file named
requirements.txt, and place the packages you need to install into that. If you install pipreqs LOCALLY, you can generate the
requirements.txt file you need. Commit that to your GitHub repo and you should be all set.
Randy, thanks much for your assistance. It is now up and running. Have a GREAT day!