Import cv2 error while deploying with streamlit

2023-08-18 15:21:28.203 Uncaught app exception
Traceback (most recent call last):
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 552, in _run_script
exec(code, module.dict)
File “/mount/src/hand_detection/hand_detection.py”, line 2, in
import cv2
ModuleNotFoundError: No module named ‘cv2’

I am getting this error while deploying.

My github repo: https://github.com/AyushMehta1702/Hand_Detection/tree/main

In my requirement.txt file, i have tried these all types of opencv installation possibilities:
opencv-python
opencv-python-headless
opencv-contrib-python-headless

But still i am getting the same above error.

In am requirements file i have used
Numpy
Opencv-python (other type also)
Streamlit
Ultralytics

Please someone help in that.
Thank you very much in advance.

Hi @AyushMehta1702,

Thank you for sharing your question with the community!

Your post is missing a code snippet and a link to your app’s GitHub repo. Please check out our guidelines on how to post an effective question here and update your post to help the community answer your question.

If you are deploying to the Community Cloud, it should be named requirements.txt. Check App dependencies - Streamlit Docs for more info.

1 Like

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