Installing OpenCV 3.0.0 with python 2.7.9 into a virtualenv on Mac OSX without homebrew

Its pretty easy to install openCV to your machine or vagrant box but its not as easy to install onto your virtualenv without brew. I enjoy brew, it has helped me tremendously and I’ve nothing against it. But I also like to have control over what I compile and where I place it.

Tested on :

Setup #

  1. Install pip, virtualenv and activate the current environment as that new env;

    $ sudo easy_install pip
    $ pip install virtualenv
    $ virtualenv env
    $ source env/bin/activate

    throughout this post dont deactivate your virtual env

    Install numpy dependency

    (env)$ pip install numpy
  2. Download opencv here and unzip it. For this tutorial this is v3.0.0.

    (env)$ cd /path/to/your/opencv-3.0.0
    (env)$ mkdir release
    (env)$ cd release
    (env)$ make -j4

    Now go make yourself some good tea and wait because this is going to take a while.

    Dont link the file to your env(ln -s This causes Segmentation Fault 11 errors which will drive you insane. Searching through Segmentation Fault 11 errors might drive you down into breaking more stuff.

    (env)$ make install
  3. Test your install

    (env)$ python
    Python 2.7.9 (default, Feb 10 2015, 03:28:08)
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cv2
    >>> cv2.__version__

(SITUATIONAL) Previous versions of Opencv #

For OpenCV V2.4.5 #

Some time ago my opencv libraries got messed up (probably because of my tinkering), I constantly got errors like

[ 66%] Building CXX object modules/ocl/CMakeFiles/opencv_test_ocl.dir/test/utility.cpp.o
Linking CXX executable ../../bin/opencv_perf_ocl
[ 66%] Built target opencv_perf_ocl
Linking CXX executable ../../bin/opencv_test_ocl
[ 66%] Built target opencv_test_ocl
make: *** [all] Error 2

To bypass this I’ve set another flag on cmake BUILD_opencv_legacy=OFF which turns off legacy support. This fixed the issue for me. #

dont forget to add your pythonpath to your ~/.profile

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

Hope this helps.


Now read this

Logitech K810 bluetooth keyboard

Connecting your logitech K810 bluetooth keyboard to your ubuntu PC and persistently retain the connection is a cumbersome process. This method automates the repairing of the K810. Installation # You should first make sure hidd is... Continue →