My streamlit app runs fine locally. I am doing image processing hence using opencv
But when I deploy the app it says no module found import cv2
I have added opencv in the requirements.txt file
The entire code is on my github here is the link: https://github.com/aniketwattamwar/Image-Processing-with-Streamlit
Any help is appreciated
Hi, @aniketwattamwar can you please share the requirements.txt file, did you correctly mention opencv, it should be mentioned as opencv-python not just opencv, if it doesn’t work then try mentioning opencv-python-headless in requirements.
I did put opencv-python
Now that you mentioned put opencv-python-headless as well.
But I am still getting the same error.
This is the error(image below)
I hosted on streamlit sharing,
so change the requirements.txt as follows
This successfully worked for me, Hope this helps @aniketwattamwar.
By the way while running the code I encountered few errors:
In Image Processing
ValueError: not enough values to unpack (expected 3, got 2)
In Feature Detection in images
AttributeError: module ‘cv2.cv2’ has no attribute ‘xfeatures2d’
After fixing the error and successfully deploying, please edit the title and add [Solved] at the beginning, it will be helpful for similar error encounters.
Thanks a ton !
It is deployed now.
As for the errors, it runs perfectly on my local machine because I have an older version of opencv
In the newer versions of opencv, algorithms like SIFT, etc are not there.
I’ll update the code accordingly
My issue is resolved
I’m having this same issue however the fix didn’t seem to work. I am using python 3.8.6 and this is what my requirements.txt looks like.
My python version was 3.6 and opecncv version was 3.4.1. I am not sure but it is just version issue.
Did you try putting opencv-python-headless ?
Maybe you could also try opencv-contrib-python.
Check out this link: https://pypi.org/project/opencv-contrib-python/
The problem can also be solved on Streamlit sharing by providing a
packages.txt file like the following: