# ImportError: cannot import name 'cv2' from 'cv2' [closed]

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


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


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.
• 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. – ghostiek Feb 17 at 9:46
• 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. – Oxbowerce Feb 17 at 9:48