AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'

May 2024 ยท 2 minute read

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 https://pypi.org/project/opencv-python/ 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

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobmtvYGt9eH%2BOmqutqpmXwrWxxKupqKpdpa6zwMiao6WxXZ67qsDImqOispWZeq67w66jnmWTq39utMCsZKenXZbBtb7Im6ytnV2crrG1jLCgqWWXqA%3D%3D