Skip to content

Instantly share code, notes, and snippets.

@ldong
Created May 16, 2016 01:02
Show Gist options
  • Save ldong/94ccde2d575326a2ca76dfae67542116 to your computer and use it in GitHub Desktop.
Save ldong/94ccde2d575326a2ca76dfae67542116 to your computer and use it in GitHub Desktop.
install opencv on mac
  1. Create a virtualenv, mkvirtualenv lookup

  2. install opencv on mac via homebrew

brew tap homebrew/science
brew install opencv
cd ~/.virtualenvs/lookup/lib/python2.7/site-packages
ln -s /usr/local/Cellar/opencv/{VERSION_NUMBER}/lib/python2.7/site-packages/cv.py cv.py
ln -s /usr/local/Cellar/opencv/{VERSION_NUMBER}/lib/python2.7/site-packages/cv2.so cv2.so

i.e.

cd ~/.virtualenvs/lookup/lib/python2.7/site-packages
ln -s /usr/local/Cellar/opencv/2.4.12_2/lib/python2.7/site-packages/cv.py cv.py
ln -s /usr/local/Cellar/opencv/2.4.12_2/lib/python2.7/site-packages/cv2.so cv2.so
  1. Test see it works or not.
workon lookup
python
import cv2

Reference

https://gist.github.com/stilist/cd7fdfabbf9ec5ed89b7

@fraser-hemp
Copy link

Don't forget to source ~/.profile to update changes.

@gerardsimons
Copy link

gerardsimons commented Sep 19, 2016

You can do python -c "import cv2" as well to make testing it a nice one-liner

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