yes, import cv2
is the correct way for now (OpenCV versions 2.x, 3.x, 4.x). it is recommended to use import cv2 as cv
for easy porting because it is planned to rename that import to simply cv
in a future release of OpenCV.
if you can’t import cv2
, the installation of the package must have failed.
python’s package index has a package called opencv-python
, which is maintained by a volunteer and tracks official releases. you can install that with pip install opencv-python
(or pip3 if you’re on linux).