I struggled for a while with Python on Mac. Here is how I finally (and easily!) installed it. Remove all the things Python you have on there already. They will probably be located at /Library/Frameworks/Python.Framework and /opt/local/var/macports/software/py26*
First download Python with Macports.
sudo port install python27
Then make sure your system is using this version with:
sudo port select --set python python27
Next install numpy with:
sudo port install py27-numpy
Now install opencv:
sudo port install opencv +python27
Now edit your ~/.bash_profile with:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.bash_profile
or
open -t ~/.bash_profile
and add the line:
export PYTHONPATH=/opt/local/var/macports/software/opencv/2.2.0_0+python27/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:$PYTHONPATH
or where ever your version of the cv.so file is hidden....
Now restart terminal and try:
%python
>>>import cv
I'm using Netbeans for opencv and python and it works really nice. Good luck.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…