在Mac OS X上配置OpenCV Python版本

转载自我的个人网站上的博客。


I didn't expect to spent 2 days to set up opencv python environment on my mbp!! Here is my advice on how to intall opencv with python support on mac os x.

0.Make sure you have homebrew installed, which is really convinient to manage software packages on mac and is easy to use.

1.First, I suggest you to uninstall all python versions that are not provided with original system.[1]

sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7

sudo rm -rf "/Applications/Python 2.7" (the Applications file is located in the root of your system, not under your username directory)

brew uninstall python  (if you have installed python with homebrew before)

2.Reinstall python by homebrew.[2]

brew tap homebrew/science

brew install python

Then set your PYTHONPATH.[3]

PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/site-packages/"

export PYTHONPATH

3.Install OpenCV

brew install opencv

4.Check it!

python

import cv2

If there's no problem, than congratulations!

5.Trouble Shooting

1.I met a confusing problem when linking opencv using homebrew. The error message was like "/some/path isn't writable". I fixed this problem by

sudo chown username /some/path

where chown means change ownership

2.You can use

brew doctor

to see if there's any problem with your homebrew management, and most wonderful thing is the doctor do provide some very useful tips!

 

Hope this article helped you. Have fun!

 

Thanks to these articles:

[1]http://stackoverflow.com/questions/3819449/how-to-uninstall-python-2-7-on-a-mac-os-x-10-6-4

[2]https://jjyap.wordpress.com/2014/05/24/installing-opencv-2-4-9-on-mac-osx-with-python-support/

[3]https://scipher.wordpress.com/2010/05/10/setting-your-pythonpath-environment-variable-linuxunixosx/


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值