Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV with Python on a mac

Hello everybody. I would appreciate if someone can help me with this.

I have installed Opencv with python on a windows PC. No problem, I am trying to do the same on a mac. (snow leopard)

However, I did the following: -Installed python 2.7 ( i know mac comes with python but i got recommended that i had to reinstall it) -Installed Numpy

So if I do something like "import numpy as np" in python, no problem.

Then I wanted to install opencv and the only option seemed MacPorts so I installed Macports and then did the

sudo port install opencv +python2.7 (sorry I dont remember exactly the grammar now)

Well, it seems that opencv is working. I made a program in C++ and build it and could get to display a jpg in a window. So no problem my opencv is working for C++

now I try to do that with python but even though I make import cv2 I get

import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named cv2

What should I do for python to recognize my opencv??

Thanks a thousand

F.Y.I I did the following: $port select python Available versions for python: none (active) python25-apple python26-apple python27

$ port installed opencv The following ports are currently installed: opencv @2.4.11_0+python27 (active)