Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I've just gone through the whole process, therefore, I find the previously given answer a bit too vague (sorry, no offence).

You will need to compile OpenCV for yourself (not daunting, I hope). And you will need to change the variable that was pointed out before, but not just this variable (PYTHON_PACKAGES_PATH) but also all those referring to PYTHON paths (starting by PYTHON2_ or PYTHON3_), for instance:

PYTHON2_EXECUTABLE PYTHON2_INCLUDE_DIR PYTHON2_LIBRARY PYTHON2_NUMPY_INCLUDE_DIRS PYTHON2_PACKAGES_PATH

In all of them, you'll need to specify the path to the anaconda installation, not the system-installed Python interpreter (CMake, the tool used to compile OpenCV might automatically find either, or even a mixture!).

I would recommend you follow a step-by-step guide if you are not familiar with the compiling process. There are plenty, for Fedora 20, which is what I am using, you can find:

http://docs.opencv.org/trunk/doc/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.html

Even if you don't have Fedora, it might be useful to check all of the CMake variables they set, since this is made to reduce the compilation time, and avoid unnecessary modules that the Python module 'cv2' might not be able to use anyway).

After the compilation, I got an IMPORT_ERROR in Python when doing 'import cv2'. In my case, this was due to the dynamic libraries of opencv trying to reach the wrong version of 'libm.so'. So, please make sure you rename your "libm.so" under the Anaconda directory to something like 'libm.so.old', so that your libopencv*.so files can find the 'proper' one installed by the system. This shouldn't break Anaconda. See the following post for details:

https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/rX_c12a7Sps

I hope this helps!