HI I receive this error during deployment. I am confused as I have import option_menu. In my conda also shows I have option_menu. I can run my whole apps before deployment. Please assist. Thanks.
ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks.
[05:06:03] Processed dependencies!
2022-08-03 05:07:22.324 Uncaught app exception
Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py”, line 557, in _run_script
File “streamlit_app.py”, line 4, in
from streamlit_option_menu import option_menu
ModuleNotFoundError: No module named ‘streamlit_option_menu’
Hi @AliceKoh! Thanks for posting.
I am confused as I have import option_menu. In my conda also shows I have option_menu.
It looks like you’re using a Streamlit component called streamlit_option_menu. The error you’re seeing likely indicates that you need to add “streamlit_option_menu” to your requirements file (requirements.txt or environment.yml)
I manage to create the requirements.txt but now has another NoModule found. This time, it says NoModule named numpy.
I post my issue under another → Numpy Error - #5 by williamlapa
Have you tried adding numpy to your requirements.txt file?
Yes I tried. I tried the below all but not working:
a) input numpy only without version at requirements.txt
b) input numpy with version 1.21.4 (my original version)
c) input numpy with version 1.21.5 (after I reinstall when no such module)
d) Currently all my app only use panda (open file, convert dictionary to dataframe, save dataframe, pycaret for model and if-elif statement. I do not use numpy. So In my apps, I tried no import numpy as np.
e) I include import numpy as np for my apps that uses pandas still keepon prompting no numpy…
f) delete the streamlit deployment and recreate with version 3.7 and 3.8
Below is my requirements.txt. Please assist.
Can you share the link to the app’s GitHub repo?
This is my github link
I re-do the requirements.text using pipreqs utf-8 which it auto generated not manually done by me. Still it fails to deploy the apps with the same error message ModuleNotFoundError: No module named ‘numpy’.
By the way, I do notice there is this error message × python setup.py egg_info did not run successfully before numpy error message. Could there be issue with setuptools? How can I check?
. Is there anything that I can delete or add to fix the issue? Really appreciate if you can assist as I put in a lot of effort into the apps which is my first data science apps. Thanks.
Marked as solved because the
ModuleNotFoundError: No module named ‘streamlit_option_menu’ was fixed by including
streamlit-option-menu in requirements.txt.
The current issue you’re facing isn’t with the custom component. It has to do with pycaret. Specifically that pycaret does a poor job of dependency resolution: [INSTALL]: pip-compile dependency hell · Issue #2837 · pycaret/pycaret · GitHub
A workaround until Pycaret fixes the dependency issues upstream is to replace your
requirements.txt with exactly the following:
And select Python 3.8 from the Advanced settings modal before deploying your app:
Once you make the above changes, your app should deploy:
I did 2 things → change requirements.txt to the 4lines, delete and redeploy using 3.8. This time the error message is No module named pycaret. Have I missed out something?
ModuleNotFoundError: No module named ‘pycaret.internal.preprocess.transformers’; ‘pycaret.internal.preprocess’ is not a package
Unfortunately, the version of pycaret that is installed in Python 3.8 does not contain the
pycaret.internal.preprocess method. You’d have to either retrain the model with this older version of pycaret or try deploying the app on an alternate platform.
It seems like Pycaret’s dependency resolution (with the newest versions) doesn’t work well on Streamlit Cloud.
May I know if I use SKlearn instead of pycaret, will the model face problem? I have never use SKLearn before and not sure if I know how to use but if it works, I will try it out.
I’m afraid that’s beyond the scope of this thread and a more general ML tooling question. It’s unlikely the pickle files are interoperable between sklearn and pycaret.
Based on your use-case, you could try creating your ML model purely with scikit-learn. They have one of the best docs out there with code examples covering a wide variety of applications:
If nothing, it would a good learning exercise. That said, if you urgently need to have your app up and running, try seeing if pycaret and your dependencies install without issues on Spaces - Hugging Face
If they don’t, it’s worth going down the sklearn route.
Thanks for taking time to assist. Glad that I manage to pick up scikit-learn and successfully deploy my first machine learning app. Though scikit is a bit antique not as glamor as Pycaret but as antique as it is, it works. I am so happy. Below is the link.