jensph jensph - 2 years ago 138
Python Question

How to install Python 2.7 bindings for OpenCV using MacPorts

When trying to "import cv" in python I get: "ImportError: No module named cv". This question has appeared in many forms, but I haven't found the answer that helps.

On my Mac OS X Lion, among many other ports, I have run:

sudo port install python27


sudo port install opencv +python27


port select python

I see: "python27 (active)"

And running:

port installed opencv

I see: "opencv @2.3.1a_1+python27 (active)"

What else should I check? Thanks.

Answer Source

I had this same problem. It looks like a (maybe?) bug with the OpenCV install script for 2.3.1a. It will not create the Python bindings unless NumPy is already installed.

To fix it:

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

That worked for me! I found this by doing some Googling, and the correct answer was here:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download