【OpenCV】 macOS Sierra下Python3.6配置

Suppose you have completed the installation of Homebrew and Python3.6.

Step 1. Download OpenCV using brew

brew install opencv

Step2. Link the downloaded OpenCV .so for Python with Python’s site package

1.cd /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
2.echo /usr/local/opt/opencv@3/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so
3.ln -s /usr/local/opt/opencv@3/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so cv2.so

Step3: Error handling

Enter Python3.6, input “import cv2”, you might get 

1.>>> import cv2
2.RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
3.Traceback (most recent call last):
4.  File "<stdin>", line 1, in <module>
5.ImportError: numpy.core.multiarray failed to import
  • Then, what you should do is merely update the numpy to the latest version, like type following in the terminal:
1.pip3.6 install -U numpy

Others: 
If you want to install OpenCV2 instead of OpenCV3, you can use 

1.brew search opencv

to find any version provided by brew. Here I have opencv (which denotes 3) and opencv@2. Currently (2018.01.09), OpenCV2 merely supports python2 while OpenCV3 offers .so to both of 2 and 3.  
If you want to install caffe and using OpenCV2, then if you use brew to install both of OpenCV2 and 3, you may need the following instruction

1.brew link opencv@2

to allow cmake find right opencv when make the file.

原地址:http://blog.csdn.net/lyrassongs/article/details/79010717

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值