This happened out of the blue, I was able to import cv2 but now I get 'AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)' error when I import it. The things I tried:

1-uninstalling and installing opencv. 2-In cmd, I typed "pip list" and opencv-python package is listed. I ran "python" command and tried importing cv2 but I get the same error. Please help.

6

8 Answers

I also had the same problem with opencv-python-4.6.0.66

I solved this error by just downgrading opencv. you can follow this command.

pip install opencv-python==4.5.5.64 

Hope this will help you.

4
pip uninstall opencv-python pip uninstall opencv-contrib-python pip uninstall opencv-contrib-python-headless 

and then

pip3 install opencv-contrib-python==4.5.5.62 
1

Same problem here when I had:

> pip list opencv-contrib-python 4.6.0.66 opencv-python 4.5.4.58 

Upgraded opencv-python to 4.6.0.66 (> pip install opencv-python==4.6.0.66) and that fixed it.

1

Updating the package to version 4.6.0.66 worked for me

I also had the same problem. I tried some of the solutions. Also, I had "ImportError: cannot import name '_registerMatType' from 'cv2.cv2' (C:\Users\user_name\anaconda3\envs\tf_od\lib\site-packages\cv2\cv2.cp39-win_amd64.pyd)" this error.

And I resolve the issue by checking OpenCV libraries installed on my Anaconda Environment by

pip list

opencv-contrib-python 4.6.0.66 opencv-python 4.6.0.66 opencv-python-headless 4.5.2.52 

I think everyone may have a different combination of these versions and others. So you should check and uninstall all OpenCV libs. And then install opencv-python.

In my case:

pip uninstall opencv-contrib-python pip uninstall opencv-python pip uninstall opencv-python-headless pip install opencv-python 

Upgrading opencv solved the issue for me: !pip install opencv-python==4.6.0.66

2

As of February 2023, had the same error with opencv-python version 3.4.4.19. Upgrading to version 3.4.5.20 solved the problem.

I changed my anaconda environment but it caused some other bugs. I just uninstall anaconda and installed it. It works now

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.