$ sudo apt-get install build-essential
$ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
$ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
$ sudo -H pip2 install -U pip numpy
$ sudo -H pip3 install -U pip numpy
$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ mkdir build
$ make
$ sudo make install
$ sudo ldconfig
$ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
$ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
$ sudo -H pip2 install -U pip numpy
$ sudo -H pip3 install -U pip numpy
$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..$ make
$ sudo make install
$ sudo ldconfig
Or more simply, this might be enough:
$ sudo apt-get install python-opencv
Or:
$ conda install -c menpo opencv3