在Mac OS X上配置OpenCV Python版本

来源:互联网 发布:java工程师工资待遇 编辑:程序博客网 时间:2024/05/19 00:16

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


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
原创粉丝点击