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 :


  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

Systematic destruction of science in Turkish society

This is a rant about an average guy from istanbul who has lived through most of the fall of democracy in Turkey(2001-2015). My observational points are from my own experiences and what friends went through. Our highschools are divided... Continue →