Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import cv2 in python in OSX

Tags:

python

opencv

I have installed OpenCV 3.1 in my Mac, cv2 is also installed through pip install cv2.

vinllen@ $ pip install cv2 You are using pip version 7.1.0, however version 7.1.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Requirement already satisfied (use --upgrade to upgrade): cv2 in /usr/local/lib/python2.7/site-packages 

But it looks like cv2 and cv cannot be used:

Python 2.7.10 (default, Jul 13 2015, 12:05:58) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: No module named cv2 >>> import cv Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: No module named cv 

I have tried almost all the solutions list online, but cannot work.

like image 624
vinllen Avatar asked Jan 18 '16 11:01

vinllen


People also ask

Why can't I import cv2 in Python?

importerror no module named cv2 error occurs when cv2 module is not properly installed or its path is not properly set or configured. The straight way fix for this error (no module named cv2) is to reinstall this module (OpenCV-python). In some scenario reinstalling this module automatically remove the older version.

Why import cv2 is not working?

The Python "ModuleNotFoundError: No module named 'cv2'" occurs when we forget to install the opencv-python module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install opencv-python command.


1 Answers

You can install by

pip install opencv-python 
like image 179
Ráfagan Avatar answered Oct 04 '22 05:10

Ráfagan