on on rasphberry pi, you have to build opencv from source.
The easiest is to get a USB flash of 8 GB or more, you must format it to NTFS or EXT4. The build needs about 6GB of space.
install required packages using
sudo apt-get install build-essential cmake pkg-config libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev libgtk2.0-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libv4l-0 libv4l-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libatlas-base-dev gfortran python-numpy python-scipy python-matplotlib libgtkglext1-dev v4l-utils python2.7-dev python3.5-dev python3-pip python3-numpy
follow the commands below but care fully.
cd ~
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip
unzip opencv.zip
if you have enough space on the PI SD card (16GB or more)
cd ~/opencv-3.2.0/
if you use the flash then
cd /media/pi/
press the tab key to autocomplete the command.
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \
-D BUILD_EXAMPLES=OFF \
-D ENABLE_NEON=ON /home/pi/opencv-3.2.0
sudo make -j4 install
A successful build will take you approximately 3.5 to 4.5 hours, the pi may slow down in speed during this point but it is worth it.
Now You Can Install using
sudo make install
REMEMBER THAT if you installed opencv using pip or pip3 you must uninstall using
pip uninstall opencv-python
or
pip3 uninstall opencv-python
Only then will opencv work for both python2 and python3 on your rasphberry pi.