Opencv安装错误

时间:2015-02-03 04:50:47

标签: python macos opencv

我用home-brew安装了opencv并在python中运行了命令import cv,这给出了以下错误。

我正在使用MAC OS 10.10。

问题是什么?

Jays-MacBook-Air:caffe jay$ brew install opencv
Warning: opencv-2.4.10.1 already installed
Jays-MacBook-Air:caffe jay$ python
Python 2.7.9 |Anaconda 2.1.0 (x86_64)| (default, Dec 15 2014, 10:37:34) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import cv
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv
>>> 

错误是什么?

我是否需要为opencv设置路径?

谢谢:)

1 个答案:

答案 0 :(得分:0)

第一步是查找cv2.so所在的位置 locate cv2.so

我的电脑输出为/usr/local/lib/python2.7/site-packages/cv2.so

然后,添加一行

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

在〜/ .bash_profile中让python找到库。