I am trying to deploy an app that uses opencv. I have tried all the permutations so far by adding “opencv-python-headless” / “opencv-python” or “opencv-contrib-python”. I have also added packages.txt to remove the error “libGL.so.1: cannot open shared object file: No such file or directory”.
But still below error exists no matter what I try .
Traceback (most recent call last):
File "detect.py", line 14, in <module>
ModuleNotFoundError: No module named 'cv2'
Contents of requirements.txt:
numpy
opencv-python
easyocr==1.4.1
matplotlib==3.4.3
matplotlib-inline==0.1.3
pandas==1.3.4
pandocfilters==1.5.0
Pillow==8.2.0
requests==2.26.0
scikit-image==0.18.3
scipy==1.7.1
seaborn==0.11.2
streamlit==1.0.0
torch==1.9.1
torchvision==0.10.1
tqdm==4.62.3
contents of packages.txt:
freeglut3-dev
libgtk2.0-dev
libgl1-mesa-glx
Kindly assist me in resolving the issue so that this error does not occur. Also, I have followed through other similar issues.
The error is caused by line 137 of your app, where you run a Python script in a subprocess.
The packages in your requirements file are installed in a virtual environment. The Python binary used in this virtual env is found at /home/appuser/venv/bin/python
In line 137 of your app, you run python detect.py --weights ... via a subprocess. This Python binary is not the one used in the virtual env where your packages, including opencv-python-headless , are installed.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.