Ask Your Question

Revision history [back]

Unable to imort OpenCV in python

I tried these instructions from Ubuntu Documentation to install OpenCV. I'm using ubuntu 16.04 64 bit. After running the script, OpenCV 3.3.0 is installed.

 Done. The new package has been installed and saved to

 /home/kvs/OpenCV/OpenCV/opencv-3.3.0/build/build_20170906-1_amd64.deb

 You can remove it from your system anytime using: 

      dpkg -r build

but I'm not able to import it in python3. Doesn't work using python2 either

kvs@Hunter:~/OpenCV$ python3
Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:09:58) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'

I also tried the command provided in the documentation for ubuntu and python, but it still doesn't work. Any help? Should install it in a different manner?

Note:- I edited the script to replace libxine-dev with libxine2-dev as suggested by the documentation.