Skip to content Skip to sidebar Skip to footer

Unresolved Reference "cv2" Inside Cv2 (cv2.cv2)

I've looked around and people seem to have similar problems but none described my case exactly, and solutions that worked for them didn't seem to work for me (or there was no answe

Solution 1:

I'm no expert but the following line worked for me:

import cv2.cv2 as cv2

Everything seems to work afterwards. Autocompletion is also back


Solution 2:

I found out that the problem is due to how cv2's __init__.py imports all the stuff, namely the globals().update() line.

In substance, everything does work, but since Pycharm doesn't index that kind of call, it doesn't detect the namespace as being properly imported. The solution would thus be to ignore the "error" and do without autocompletion.


Solution 3:

Have you installed opencv via terminal?

For example, like this.

$ pip install opencv-python
$ pip install opencv-contrib-python

I also experienced the same problem.

If you use pycharm, you should install opencv via pycharm.

File -> Settings... -> Project interpreter -> +


Solution 4:

I got this same issue. You need to try a couple of things.

  1. You need to simply import cv2 instead of cv2.cv2. Simply write "import cv2"
  2. If you have installed any other library such as cv before, then uninstall it first.
  3. The library that we need to install is opencv-python
  4. You need to install it via IDE not with the terminal. Steps are as follows: File -> Settings -> (Click on your project) -> Project Interpreter -> + -> (Type opencv-python) -> Download and install it -> It should work now.

Post a Comment for "Unresolved Reference "cv2" Inside Cv2 (cv2.cv2)"