I'm using anaconda and installed OpenCV using conda-forge.

conda install -c conda-forge opencv

In my notebook I run this line of code

from cv2 import cv2

Unfortunately, get this error message:

ImportError: cannot import name 'cv2' from 'cv2' (C:\Users\...\Anaconda3\envs\...\lib\site-packages\cv2.cp38-win_amd64.pyd)

The weird thing is importing cv2 and running its functions works just fine.

# Works just fine
import cv2
img = cv2.imread('snek.jpg')

Here are some informations about my system if that helps?

conda version : 4.9.2
conda-build version : 3.20.5
python version : 3.8.5.final.0
platform : win-64

1 Answer 1


If you want to use the opencv module you import this by running import cv2. The code you want to run tries to import a function/module called cv2 from the cv2 package, which does not exist.

  • $\begingroup$ Oh, apologies. I assumed that would work since that's the code that I was asked to work on. I guess if I wanted the code to work as is I could just run from cv2 import * but I'll just use import cv2 and refactor the code. Thanks for your help. $\endgroup$
    – ghostiek
    Feb 17, 2021 at 9:46
  • $\begingroup$ Using from cv2 import * will import all underlying functions and modules, e.g. cv2.imread could then be used by calling just imread. If you import the top level cv2 package all functions will have to be called by using cv2.function_name. Hope that clears things up. $\endgroup$
    – Oxbowerce
    Feb 17, 2021 at 9:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.