Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing opencv for python 2.7 on a MAC

I installed opencv via the command pip install opencv-python and then when I import cv2 in python I get the error ImportError: dlopen(/Library/Python/2.7/site-packages/cv2/cv2.so, 2): Symbol not found: _clock_gettime

I would like to install opencv for python 2.7 on a mac. How can I resolve this error ? I am using El Capitan.

I installed opencv prior to this using brew install opencv but then I uninstalled it using brew uninstall opencv before using pip.

like image 222
marc Avatar asked Dec 10 '22 08:12

marc


2 Answers

This works !

sudo pip install opencv-python==3.3.0.10

El Capitan has an issue detailed here http://answers.opencv.org/question/182067/import-cv2-throws-symbol-not-found-_clock_gettime/

In order to circumvent this issue, I rolled back to an earlier version of opencCV.

A trick to check the available version with pip do

sudo pip install opencv-python==

This will return all the available version and then you can try the ones that work for you.

Dont forget to pip uninstall when moving to a different version

like image 185
marc Avatar answered Dec 12 '22 22:12

marc


It looks like this is an issue with python-opencv and the mac operating system That you are using. From the link below it looks like Apple changed something to do with _clock_gettime function, meaning the maintainers of python-opencv will need to update.

The commenters on the post below managed to fix the issue by upgrading to Sierra

http://answers.opencv.org/question/182067/import-cv2-throws-symbol-not-found-_clock_gettime/

like image 40
GPPK Avatar answered Dec 12 '22 20:12

GPPK