ModueNotFoundError:No module named ‘cv2’ had been posted with a solution in Oct 2021. The same error seems to has come back. The previous solution didn’t work. So, I’m posting my question here.
The app that used opencv was deployed to streamlit cloud and has been working well for the past several weeks.
I changed some minor wording in the code on Feb 3, 2022 and verified that the app worked on my laptop (i.e. local host).
The streamlit cloud now showed an error “No module named “cv2”” when my app was rebooted and run.
I’ve read the relevant postings in this forum and tried the recommended solutions as follows.
(1) Use opencv-python-headless in requirements.txt
(2) Tried packages.text with
Nothing worked for me. I’m still getting the error message.
Thank you for your prompt response to my question.
I’ve changed the version of streamlit-webrtic to 0.34.2 in the requirements.
A different error message read as follows.
ImportError: cannot import name ‘_registerMatType’ from ‘cv2.cv2’ (/home/appuser/venv/lib/python3.8/site-packages/cv2/cv2.cpython-38-x86_64-linux-gnu.so)
Attached is the error log from streamlit cloud.
Thanks,
(Attachment logs-testruncoder-cv2bugtest-master-streamlit_app.py-2022-02-07T20 06 12.653Z.txt is missing)
Just FYI, I’ve always used Python 3.8, not 3.7, in developing my codes. I presume that my previous deployment to streamlit cloud used Python 3.8.
I can’t wait to see this problem resolved.
Thanks,
By the way, I didn’t have this error with streamlit cloud until Feb 3rd, 2022.
I’m wondering what might have been changed with pip on streamlit cloud settings.
Sorry, I’m not a highly experienced programmer and couldn’t understand your question.
What file else do I need to lock the dependencies to the repository?
No worries! We tried to upgrade multiple apps in Cloud to use the latest base images, and this might have caused some issues for a few existing apps. We are working on identifying the best solution.
I think you meant that the requirements.txt listed all the dependencies.
Requirements.txt has been created locally by ‘pip freeze > requirements.txt’.
It’s a long list and can be viewed in the github link as shown above.
A different error message came out this time:
The error log has been downloaded. I’m no sure how to attach the error log text file here.
The last portion of the error log reads as follows.
Collecting pytz-deprecation-shim==0.1.0.post0
Downloading pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl (15 kB)
ERROR: Could not find a version that satisfies the requirement pywin32==303 (from versions: none)
ERROR: No matching distribution found for pywin32==303
[manager] installer returned a non-zero exit code
[manager] Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[manager] Streamlit server consistently failed status checks
[manager] Please fix the errors, push an update to the git repo, or reboot the app.
Thanks @funcode ! I will investigate based on the information you provided. Until I get to the root cause, and I know you usually use Python 3.8 and this might lead to other issues, but you can create a branch and deploy to Python 3.7 to avoid this issue.
Hello, I’m having the same issue.
This is my repo: GitHub - angelicaba23/app-super-resolution
I already tried with py 3.7, 2.8 and 3.9 and doesn’t work when deploying but local it is great!
If OpenCV is installed on your system but Python cannot find it, you will get the “no module named ‘cv2’” error message. This can happen if OpenCV is not in the Python path. The Python path is a list of directories where Python looks for modules and packages. You can check the Python path by running the following command in your terminal or command prompt:
python -c "import sys; print(sys.path)"
This will print out the directories in the Python path. Make sure that the directory where OpenCV is installed is included in the Python path.
@linehammer, is your recommended step working on a heroku server? I had no problem with running the code on a local driver. The problem takes place when the code is run from a heroku server.
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.