How to import opencv in python on clear linux?

I have already installed computer-vision-basic. Then doing:

  1. python (ok)
  2. import opencv (fail)

msg:
root@clr-1c ~ # python
Python 3.7.2 (default, Mar 1 2019, 00:40:03)
[GCC 8.3.1 20190228 gcc-8-branch@269272] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import opencv
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘opencv’

someone could help to solve this. I have no idea now.

pip install opencv-python
python
>>> import cv2

OpenCV is a library of programming functions mainly aimed at real-time computer vision. Originally developed by Intel, it was later supported by the Willow Garage then Itseez. The library is cross-platform and free for use under the open-source BSD license.

To work with OpenCV in Python, we have to install the opencv-python module.

Type the following command.

python3 -m pip install opencv-python

# OR

pip install opencv-python

To use the opencv-python in our project, we have to import the cv2 module in the file.

import cv2

Now, for example, To read image using OpenCV, you will write the following code.

cv2.imread(path, flag)

I hope it helps you see the complete scenario.

Best Regards,

1 Like