在Mac上将Python与Open CV链接

问题描述:

我正在努力安装OpenCV以在Mac上使用Python http://www. jeffreythompson.org/blog/2013/08/22/update-installing-opencv-on-mac-mountain-lion/

I was working to install OpenCV to work with Python on my Mac http://www.jeffreythompson.org/blog/2013/08/22/update-installing-opencv-on-mac-mountain-lion/

我安装了所有东西,都没有问题,但是最后我遇到了有线问题,提到"OpenCV库"未连接

I got everything installed without problems, but by the end I got this wired problem mentioning that the "OpenCV library" is not connected

$ pkg-config --cflags opencv
-I/usr/local/include/opencv -I/usr/local/include 

$ brew install opencv
Warning: opencv-2.4.6.1 already installed, it's just not linked

$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import cv
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv
>>> import cv

对于它的价值,我认为您只是错过了

For what it's worth, I think you just missed a step in my instructions. You need to add the following line to your .bash_profile file in your Home folder (or create it if the file doesn't exist):

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

在启动Python之前,请确保重新启动Terminal.

Be sure to restart Terminal before starting Python.