问题描述:

I am having trouble getting OpenCV to work with Python on my Mac.

I have tried installing it with MacPorts and with Cmake (which I installed from MacPorts) using the methods found at here: http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port. I also had to download Xcode to make MacPorts work.

I ran sudo port -v install opencv +python27 and it seemed to work fine. However when I tried to import OpenCV in Python using import cv, the module could not be found.

If any of this information helps, I have OSX 10.6.8 Snow Leopard, python 2.7.3, and am trying to install OpenCV 2.4.3. I am not a very experienced programmer so my troubleshooting attempts are falling short of a solution.

Any help is appreciated. Thanks!

网友答案:

I haven't tried the MacPorts installation, but you might want to try this:

import cv2
from cv2.cv import *
网友答案:

I had the same problem, it seems that the OpenCV Python Bindings don't get installed without numpy preinstalled; you can use these commands:

sudo port uninstall opencv
sudo port install py27-numpy
sudo port install opencv +python27

As in this question: How to install Python 2.7 bindings for OpenCV using MacPorts

相关阅读:
Top