Pulse99
Posts: 1
Joined: Sun May 10, 2015 9:08 am

OpenCV on python3 - import cv fail

Sun May 10, 2015 9:17 am

I tried to install opencv3 rc1 in the Rpi doing the make and make install it take me 10 hours but when I try to import cv2 or import cv3 it didnt work(Import Error: No Module named cv2), it only work for python2, I used ccmake following some tutorials, this are the screen for the ccmake I use almost the default configuration.
Image
Image

LinuxCircle
Posts: 26
Joined: Sat May 04, 2013 2:03 am
Contact: Website

Re: OpenCV on python3 - import cv fail

Tue May 19, 2015 3:36 am

Make sure you install all dependencies:

Install core dependencies

Code: Select all

 sudo apt-get install cmake python3-dev python3.2-dev python3-numpy gcc gcc-c++ build-essential cmake-curses-gui
 
Install other dependencies

Code: Select all

 sudo apt-get -y install pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools libeigen3-dev

Install helper apps

Code: Select all

 sudo apt-get -y install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev swig libv4l-0 libv4l-dev libpython3.2 libgtk2.0-dev
As well as call the right parameters related to Python 3 libraries and folders (copy and paste exactly including the ..):

Code: Select all

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") -D PYTHON_EXECUTABLE=$(which python3) ..

Code: Select all

make -j4
If you utilise all the 4 core processors, it should only take you around 45 minutes, not 10 hours on Raspberry Pi 2.

Code: Select all

sudo make install
Always follow: http://www.linuxcircle.com/2015/05/18/o ... erry-pi-2/
www.linuxcircle.com

Return to “Troubleshooting”