tags:

views:

263

answers:

3

HI! I'm trying to install opencv and use it with python, but when I compile it I get no errors but I can't import cv module from python:

patrick:release patrick$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
[GCC 4.2.1 (Apple Inc. build 5646)] 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

The code I used to compile it is this:

cd opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON
make
sudo make install

how can I get it working with python?

A: 

You could try ctypes-opencv -- not sure why building and installing with -D BUILD_PYTHON_SUPPORT=ON didn't work for you (maybe it doesn't know where to install the Python wrappers in osx...?), but the ctypes wrappers should, in theory, work anyway.

Alex Martelli
the build_python instruction seems to be not working because it doesn't create the cv.pyd (it creates only cv.so). Anyway I just tried ctypes-opencv and I get this error: http://dpaste.com/221536/
patrick
+1  A: 

I posted a blog post showing how to install OpenCV 2.1 on Snow Leopard. Maybe you can check it out.

Sunny
thanks but it doesn't work for me :(
patrick
Are you getting the same error?
Sunny
+1  A: 

Try MacPorts. It's definitely the easiest way to get OpenCV running on OS X, including Python. I found 2.0 to be a little buggy, but 2.1 is great. 2.1 isn't yet in the MacPorts repo, but it should be soon -- see the discussion at ticket 24503. Worst case, you can download the portfile from that ticket and install it locally, which is what I did.

Josh Bleecher Snyder
Macports now downloads v. 2.1