Skip to content

Instantly share code, notes, and snippets.

@stilist
Created July 3, 2014 21:46
Show Gist options
  • Save stilist/cd7fdfabbf9ec5ed89b7 to your computer and use it in GitHub Desktop.
Save stilist/cd7fdfabbf9ec5ed89b7 to your computer and use it in GitHub Desktop.
Installing OpenCV on OS X (using Homebrew)

Based on http://jjyap.wordpress.com/2014/02/21/installing-opencv-2-4-8-on-mac-osx-with-python-support/

  1. edit .bashrc or .bash_profile to include: export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.7/site-packages/:$PATH"
  2. brew update
  3. brew tap homebrew/science
  4. brew install opencv
  5. cd /Library/Python/2.7/site-packages/
  6. ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.py
  7. ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so cv2.so

To verify, run python and try import cv2. If it doesn’t throw a No module named cv2 error, you’re good.

@ldong
Copy link

ldong commented May 16, 2016

Thanks.

Here's my version of linking opencv with virtualenv-ed python, gist link

@atrij
Copy link

atrij commented Jun 8, 2016

if "No module named cv2"?

@antoniopresto
Copy link

Try to add the following line in ~/.bashrc
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

@http://stackoverflow.com/a/21131649/3984709

@Omar-Salem
Copy link

Thanks alot

@leeowen
Copy link

leeowen commented Apr 18, 2018

Thanks a lot :D

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