Ask Your Question

Problems installing opencv on mac with python

asked 2012-09-19 08:46:41 -0600

uqarni gravatar image

updated 2012-09-19 08:47:05 -0600


Is there ANYWHERE with a functional step-by-step-by-step guide to doing this? I've tried everything I've found after hours and hours of googling (so please do not link opencv wiki or other top search result), but none of it works! I still get the module doens't exist.

Thank you very much!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-09-19 13:26:14 -0600

updated 2012-09-30 07:13:23 -0600


I had installed OpenCV with python on my mac using homebrew without any problems about 6 months ago:

  1. $brew install opencv

  2. Homebrew printed a message after installation that I need to specify the python path correctly and I added this line in my .bash_profile:

    export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"

It worked for me perfectly (for example, I have autocompletion of the OpenCV Python interface in MacVim).

UPD: Also if you run $brew info opencv then homebrew will print this information about Python bindings:

==> Caveats

The OpenCV Python module will not work until you edit your PYTHONPATH like so:
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"

To make this permanent, put it in your shell's profile (e.g. ~/.profile).

edit flag offensive delete link more


Hi there, thanks for the response.

Do I have to install Python through Homebrew for this to work? Before or after I install opencv? Any specific version of Python? Once I install Python, how do I get to a point where I can click on an application on my dock that opens that allows me to code in Python using OpenCV?

Sorry for the basic questions- I'm new to Mac and this has been infinitely more complex than on PC.

uqarni gravatar imageuqarni ( 2012-09-19 19:24:13 -0600 )edit

I don't remember exactly but I think Python is pre-installed on Mac so you don't need to install it.

Read carefully last lines of console output after "$brew install opencv", try to spot the information about PYTHONPATH or something related and do exactly as it says.

First of all, try to reach the point where you can run OpenCV python samples without error. For example, download source code of OpenCV, cd to its directory and run the command in console:

python samples/python2/

Ilya Lysenkov gravatar imageIlya Lysenkov ( 2012-09-20 12:27:15 -0600 )edit

The Homebrew formula for opencv is messed up as of today; it doesn't install Python bindings. See

Matt M gravatar imageMatt M ( 2014-02-08 19:39:59 -0600 )edit

Question Tools


Asked: 2012-09-19 08:46:41 -0600

Seen: 5,273 times

Last updated: Sep 30 '12