0
votes

I've a Mac (OS X 10.7.3 64 bit) and am working with OpenCV and Python.

I was able to install OpenCV using MacPorts with support for Python.

I installed the 2.7 Python interpreter, exported the site-packages to PYTHONPATH(this is where the location of my cv2.so and cv.py are).

I am able to run my OpenCV Python programs via the command line.

I installed Eclipse + PyDev, chose the same interpreter.

Now, in the Project properties for any project I create, I add the site-packages dir in the system libraries. If I save and run, I get the following error:

File "/Users/harishvenkatesan/Documents/Eclipseworkspace/helloworldpython/src/org/eclipse/python/standard.py", line 10, in <module>

import cv

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv.py", line 1, in <module>

from cv2.cv import *

ImportError: dynamic module does not define init function (PyInit_cv2)

It seems like PyDev found the location alright, since from cv2.cv import * is the statement in cv.py. But I am not able to fix this error. I did a few searches online, but couldn't find any solutions.

Does anyone have an idea about this? Much appreciated! My Eclipse and everything else is 64-bit, so I am not sure if this is a 32-64 bit mismatch.

1

1 Answers

0
votes

Instead of

import cv

I use

import cv2.cv as cv

and it works. Hope it will work for you too :)