install opencv python mac osx 10.11?

2k views Asked by At

I'm trying to install opencv so I can use it in a python program. My computer is a little old and I can't update osx past 10.11. Is it still possible to install opencv? I don't need it to be opencv4 if that's an issue.

I've tried using pip, pip3, and homebrew. They all download it and then it won't actually import in python correctly. Everything eventually says that it needs to be osx 10.12.

Here's the exact error I'm getting:

File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.7/site-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: dlopen(/anaconda3/lib/python3.7/site-packages/cv2/cv2.cpython-37m-darwin.so, 2): Symbol not found: _clock_gettime
  Referenced from: /anaconda3/lib/python3.7/site-packages/cv2/.dylibs/libavutil.56.22.100.dylib (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib
 in /anaconda3/lib/python3.7/site-packages/cv2/.dylibs/libavutil.56.22.100.dylib

Thanks!

1

There are 1 answers

1
BPDESILVA On

Try conda install :

conda install --channel https://conda.anaconda.org/menpo opencv3

OR

conda install -c menpo opencv 

Then import

import cv2

There seems to be a problem with the brew installation according to https://github.com/Homebrew/homebrew-science/issues/3024 but you can try the below too

---------- OR ----------

First, create a venv (Virtual Enviorment)

python3 -m venv /path/to/new/virtual/environment

Then using brew :

brew uninstall opencv
brew install opencv3

OR

Then using pip :

pip3 install opencv-python

Finally, import using :

import cv2

This should work but in the case doesn't it might mean that you've installed anaconda with python in that case try:

conda install -c menpo opencv 

Finally, import using :

import cv2