mac os+python3+opencv3环境配置

环境:macOS python3.5.2 

安装: opencv3.2

思路:终端可以直接安装OpenCV,但还不能直接用,需要将cv2链接到python3类库目录下之后才能用。

 

step1:用终端安装opencv

$ brew install opencv3--with-python3 --c++11 --with-contrib --with-ffmpeg --without-python

注:python2python3一次只能装一个,用without-python可以跳过python2opencv装在python3里。

 

step2:找到python3类库目录site-packages

$ python3
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 262016, 10:47:25)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]on darwin
Type "help","copyright", "credits" or "license" for moreinformation.
>>> import numpy
>>> print(numpy.__file__)
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/__init__.py

 

step3:cv2链接到python3类库目录,command+d跳出pythonshell,在新建终端进行:

$ cd/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ 
$ ln -s/usr/local/Cellar/opencv3/3.2.0/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so

 

step4:测试一下

$ python3 
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 262016, 10:47:25)  
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]on darwin 
Type "help","copyright", "credits" or "license" for moreinformation. 
>>> import cv2 
>>>  

没有报错,说明安装成功:)


你可能感兴趣的:(mac os+python3+opencv3环境配置)