Mac安装Python版OpenCV

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

1. brew安装opencv

1
2
3
brew install homebrew/science/opencv

brew install homebrew/science/opencv3

2. 把opencv添加到python中

执行下面的命令,或直接将/usr/local/Cellar/opencv3/3.1.0_4/lib/python2.7/site-packages/下的cv2.so拷贝到/Users/ltc/anaconda/lib/python2.7/site-packages/目录中。

1
echo /usr/local/Cellar/opencv3/3.1.0_4/lib/python2.7/site-packages/ >> /Users/ltc/anaconda/lib/python2.7/site-packages/opencv3.pth

3. 测试

1
2
$ python
$ import cv2

不报错,安装成功。

如果有收获,可以请我喝杯咖啡!