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.
The source code can be found:
The code was deployed to streamlit cloud:
Here’s the requirements.txt.
I’m wondering if there has been any change to libraries or versions on streamlit cloud.
I would greatly appreciate any help to resolve the issue.
Hi @funcode -
If I’m not mistaken, the streamlit-webrtc package was using an internal API that was deprecated, which temporarily broke some apps.
Your requirements.txt is showing 0.32.0; can you try the newest version 0.34.2?
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.
(Attachment logs-testruncoder-cv2bugtest-master-streamlit_app.py-2022-02-07T20 06 12.653Z.txt is missing)
Hi @funcode! I’m helping Randy investigate this issue. From what I can see in the logs, it is now returning an error because it is hitting this issue python - cannot import name '_registerMatType' from 'cv2.cv2' - Stack Overflow .
I’ve forked your repository and deployed your application on Python 3.7 (by accident) and it worked. I’m trying to reproduce this on Python 3.8.
Hi Alex, thank you for your help.
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.
Could you share what version of pip you are using locally? Could you add a file to lock the dependencies to your repository?
pip 21.3.1 on my laptops.
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.
Can you try something like this python - Automatically create requirements.txt - Stack Overflow to generate a requirements file.txt file?
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.
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.
Thanks, Alex. I’ll go ahead deploy my apps with Python 3.7 in the meantime.
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!
Have you tried streamlit==1.3.0, opencv-python-headless==220.127.116.11 and python==3.7?