AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)
Asked Answered
O

9

58

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.

Ohalloran answered 21/6, 2022 at 19:17 Comment(6)
Does this answer your question? AttributeError: partially initialized module 'cv2' has no attribute 'CascadeClassifier' (most likely due to a circular import)Clupeoid
I've already tried that solution does not work.Relentless
and how's this? #72546279Clupeoid
@ÖmerFarukAydın Create a new virtual environment, install OpenCV and tryEpanorthosis
I changed my anaconda environment but it caused some other bugs. I just uninstall anaconda and installed it. It works nowRelentless
I found a dirty fix: https://mcmap.net/q/82410/-cannot-import-opencv-because-of-circular-importWield
L
77

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.

Landy answered 30/6, 2022 at 8:49 Comment(4)
for me (in a container) pip install opencv-python-headless==4.5.5.64 worked. The newest version, albeit also headless, did not work, it showed a different error.Lifework
If your issue is indeed that the currently installed package is out of date, pip install opencv-python --upgrade will get you the latest one.Oratorical
it worked for me and the git-sym package! thank youCaret
what if i need opencv-python>=4.6?Desiraedesire
R
42
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
Redeemer answered 25/6, 2022 at 22:18 Comment(1)
thanks sir! this helped me out today with a scary issueForme
C
7

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.

Crew answered 20/10, 2022 at 10:52 Comment(1)
Thanks. Just in case, to get the list pip list | grep opencvKaufman
K
2

Updating the package https://pypi.org/project/opencv-python/ to version 4.6.0.66 worked for me

Krein answered 25/6, 2022 at 10:5 Comment(0)
K
2

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
Knitting answered 29/10, 2022 at 13:46 Comment(0)
G
1

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

Grime answered 10/8, 2022 at 9:48 Comment(2)
Please don't add "thank you" as an answer. Once you have earned 15 reputation points you will be able to vote other users' posts up.Bush
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From ReviewGamut
L
1

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.

Lounge answered 20/2, 2023 at 6:51 Comment(0)
O
0

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

Ohalloran answered 22/6, 2022 at 15:21 Comment(0)
J
0

It might to be the version of "opencv-contrib-python" and "opencv-python" should be consistent.

Juggins answered 6/4 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.