cmake -DPYTHON_LIBRARY=/opt/anaconda/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/opt/anaconda/include/python2.7 -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=OFF -DBUILD_DOCS=OFF -DBUILD_TESTS=OFF -DBUILD_WITH_DEBUG_INFO=OFF -DBUILD_opencv_apps=OFF -DBUILD_EXAMPLES=OFF -DBUILD_opencv_python=ON ..
You have to define PYTHON_LIBRARY
and PYTHON_INCLUDE_DIR
variables explicitly, or OpenCV may not find PythonLibs.