Here's my saga. It's heavily based on this earlier gist, but adapted for Mavericks. I'm starting off from pyenv
running anaconda-1.9.1
.
I tried several versions, but only 2.4.8 compiled successfully for me.
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.8/opencv-2.4.8.zip
unzip opencv-2.4.8.zip
cd opencv-2.4.8
Let's build it! You'll need cmake, pretty sure I got this from brew install cmake
.
mkdir release
cd release
cmake \
-DPYTHON_INCLUDE_DIR=$HOME/.pyenv/versions/anaconda-1.9.1/include/python2.7 \
-DPYTHON_LIBRARY=$HOME.pyenv/versions/anaconda-1.9.1/lib/libpython2.7.dylib \
-DPYTHON_EXECUTABLE=$HOME/.pyenv/versions/anaconda-1.9.1/bin/python \
-DPYTHON_PACKAGES_PATH=$HOME/.pyenv/versions/anaconda-1.9.1/lib/python2.7/site-packages \
..
If it all builds successfully, you can now run make install
.
I also had to manually fix the python module in order to work:
sudo install_name_tool -change libpython2.7.dylib ~/.pyenv/versions/anaconda-1.9.1/lib/libpython2.7.dylib ~/.pyenv/versions/anaconda-1.9.1/lib/python2.7/site-packages/cv2.so
At the end of all of this, you should be able to run
$ python
>>> import cv2
without a segfault.
+1 for not cheating and using Vagrant