Skip to content

Instantly share code, notes, and snippets.

@frederikhermans
Last active January 4, 2016 03:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frederikhermans/8561382 to your computer and use it in GitHub Desktop.
Save frederikhermans/8561382 to your computer and use it in GitHub Desktop.
Install opencv in current homebrew (Error: undefined method `incdir' for #<PythonDependency: "python" []>)

Installing opencv fails, even though $ brew doctor doesn't have any complaints:

$ brew install opencv
==> Downloading https://github.com/Itseez/opencv/archive/2.4.7.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/opencv-2.4.7.1.tar.gz
==> Patching
patching file cmake/OpenCVFindOpenNI.cmake
Warning: Formula#python is deprecated and will go away shortly.
Error: undefined method `incdir' for #<PythonDependency: "python" []>
Please report this bug:
    https://github.com/Homebrew/homebrew/wiki/troubleshooting
/usr/local/Library/Formula/opencv.rb:50:in `install'
/usr/local/Library/Homebrew/build.rb:165:in `install'
/usr/local/Library/Homebrew/formula.rb:272:in `brew'
/usr/local/Library/Homebrew/formula.rb:617:in `stage'
/usr/local/Library/Homebrew/resource.rb:63:in `unpack'
/usr/local/Library/Homebrew/extend/fileutils.rb:21:in `mktemp'
/usr/local/Library/Homebrew/resource.rb:60:in `unpack'
/usr/local/Library/Homebrew/resource.rb:53:in `stage'
/usr/local/Library/Homebrew/formula.rb:615:in `stage'
/usr/local/Library/Homebrew/formula.rb:267:in `brew'
/usr/local/Library/Homebrew/build.rb:144:in `install'
/usr/local/Library/Homebrew/build.rb:45:in `main'
/usr/local/Library/Homebrew/build.rb:12
/usr/local/Library/Formula/opencv.rb:81

Looking at the commit history, you can see an entry PythonDependency: massive refactoring.:

commit b3f4929f9d753ec7fb587cfbb065884d659fb81f
Author: Mike McQuaid <mike@mikemcquaid.com>
Date:   Sat Jan 4 13:18:42 2014 +0000

    PythonDependency: massive refactoring.

    Closes #24842.

commit 0313168fc9287710c22e792c5581cd545ae52b59
Author: Mike McQuaid <mike@mikemcquaid.com>
Date:   Mon Jan 20 15:26:18 2014 -0800

    bottle: only print relocations with --verbose.

Let's roll back to the commit just before that:

$ cd /usr/local
$ git reset --hard 0313168fc9287710c22e792c5581cd545ae52b59
HEAD is now at 0313168 bottle: only print relocations with --verbose.

Try again to build opencv:

$ brew install opencv
==> Downloading https://github.com/Itseez/opencv/archive/2.4.7.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/opencv-2.4.7.1.tar.gz
==> Patching
patching file cmake/OpenCVFindOpenNI.cmake
==> cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencv/2.4.7.1 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=O
==> make
==> make install
==> Caveats
Set PYTHONPATH if you want Python to find your site-packages:
  export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
==> Summary
🍺  /usr/local/Cellar/opencv/2.4.7.1: 217 files, 40M, built in 3.9 minute

Hooray! Now let's go back to the latest brew version: $ brew update .

@petersmagnusson
Copy link

thank you! :-)

@jeffpolk230
Copy link

Thanks, it works on my machine.
also, for who wants to use python part of OpenCV, here's another post for additional one step to setup python path
http://luxfero.com/instalar-opencv-en-mac-os-x-10-9/

@mmontag
Copy link

mmontag commented Feb 9, 2014

Thanks, I did brew install opencv without error, but the Python bindings weren't getting built.
Rolling back to this commit fixed my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment