Ask Your Question
2

Problems installing opencv on mac with python

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

uqarni gravatar image uqarni
17 4

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

Hi,

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!

delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
2

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

Ilya Lysenkov gravatar image Ilya Lysenkov
816 1 11 19
http://twitter.com/ilysen...

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

Hi,

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).

link delete flag offensive edit

Comments

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 ( 2012-09-19 19:24:13 -0500 )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/browse.py

Ilya Lysenkov ( 2012-09-20 12:27:15 -0500 )edit

The Homebrew formula for opencv is messed up as of today; it doesn't install Python bindings. See https://github.com/Homebrew/homebrew-science/issues/664

Matt M ( 2014-02-08 19:39:59 -0500 )edit

Login/Signup to Answer

Question tools

Follow

subscribe to rss feed

Stats

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

Seen: 1,883 times

Last updated: Sep 30 '12