简体   繁体   中英

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.

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM