Bag of ML Words

ML = Machine Learning, Music Love, and Miscellaneous things in daily Livings

OpenCV python wrapper install on Ubuntu 14.04 (w/ anaconda)

I tried many and finally succeeded in installing OpenCV python wrapper on Ubuntu 14.04. 

I use the Anaconda package for the main python library, thus all python-related dependencies would watch for the Anaconda package directory. That was the trouble for me. 


Useful references: 

1. Installing OpenCV 2.2 in Ubuntu 11.04 – Sebastian Montabone

2. LIBTIFF_4.0 link errors - OpenCV Q&A Forum




First, download the installation package of OpenCV (for linux) from the official site. 

I used the OpenCV-2.4.10. 

Unpack it and go to the directory. Then, create a working directory for build. 


cd opencv-2.4.10

mkdir build

cd build

Next, prepare all necesarry libraries by apt-get. 

Please find the reference 1. Before apt-get install, you may remove "libopencv*" from your system (to avoid unnecesarry conflictions). 


Now we are ready to try building the OpenCV

We start from making the Makefiles by cmake. In cmake, you need to be careful on the option arguments because we rely on Anaconda package. 

Finally the command below yielded the successful installatoin: 




-D PYTHON_EXECUTABLE=(anaconda dir path)/bin/python

-D PYTHON_LIBRARY=(anaconda dir path)/lib/ \

-D PYTHON_INCLUDE=(anaconda dir path)/include/python2.7 \ 

-D PYTHON_PACKAGES_PATH=(anaconda dir path)/lib/python2.7/site-packages \ 


-D CMAKE_C_COMPILER=/usr/bin/gcc

-D CMAKE_CXX_COMPILER=/usr/bin/g++ ../


Type the above command, and cmake wil return the specifications for making the OpenCV library. Read the specifications carefully, and correct the options if something is wrong. 


make and make install

If you are good, then make. This will take a while. After that, make install with sudo. 


sudo make install

If there are some errors during make, you need to fix it one by one. Typically I encountered with missing lib****, which we can solve instantly by apt-get.  


First, check out if openCV module is loadable from your python (in anaconda):  

import cv2

If no errors, congratulation! You passed the first test. :-) 


Second, you would write a simple code that uses cv2 functions. Some of OpenCV functions may not be builded appropriately even if the installation finished without apparent errors && the cv2 module is loadable.

In my system I frequently encountered with problems on video (movie) processing functions :-( 


If you encounter the linker problem of GLIBC with (like me), you may copy from /lib/x86_64-linux-gunu/ to anadonda/bin/../lib/. 

Be sure to keep the original (that of anadonca) as a different file!

Import Error: `GLIBC_2.15' not found - OpenCV Q&A Forum



No errors? Have fun with OpenCV!! ;-)