Installing opencv3 with python3.6
$ brew update
$ brew install opencv3 --with-python3 # Add --with-contrib if you want the contrib modules
$ ln -s /usr/local/opt/opencv3/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so /usr/local/lib/python3.6/site-packages/cv2.so
You may have to export PYTHONPATH
:
export PYTHONPATH=$PYTHONPATH:/usr/local/Cellar/opencv3/3.4.0/lib/python3.6/site-packages
If you installed a previous version of opencv and no longer need it, remove it:
brew cleanup opencv
Test:
$ python3
In[1]: import cv2
In[2]: cv2.__version__
Out[2]: '3.4.0'