I had the same problem. OpenCV Python bindings seem to be built and installed, but they are not listed in the site-packages directory. I found a solution by adding a symlink to the embedded file "cv.so" in the "site-packages" directory of the Python package installed by MacPorts. These instructions are tested during setup using Mac OS 10.6.6. MacPorts object packages are python27 and opencv.
To make sure that the Python bindings are actually on your disk, you need to make sure that you invoke the opencv package with the python option:
sudo port install opencv +python27
The cv.so shared object file will be created in the following directory:
/opt/local/@@PYTHON_PKGD@@
You will need to create a symbolic link in the Python "site-packages" directory. You can find the path to this directory by executing these commands in the Python interpreter:
from distutils.sysconfig import get_python_lib print get_python_lib()
The returned path should look like the following:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Create a symbolic link to the shared object ("cv.so") in this directory:
ln -s /opt/local/@@PYTHON_PKGD@@/cv.so /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv.so
Now you can import the cv module into your interpreter:
import cv
Your installation may be slightly different if you are using a different version of Python or OpenCV; however, the general methodology should be the same, with the exception of path names. There may be a better way to do this, but this methodology works well.
rype
source share