Reputation: 93
Any solution for this error ?, need help :(
I import cv2 in python3:
import cv2
and it results like this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/cv2/__init__.py", line 4, in <module>
from .cv2 import *
ImportError: libQtTest.so.4: cannot open shared object file: No such file or directory
Upvotes: 9
Views: 17254
Reputation: 176
Here are the steps to solve your problem
sudo pip3 uninstall opencv-python
` 2. install opencv using the CMake
sudo apt-get install build-essential cmake pkg-config -y
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev -y
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y
sudo apt-get install libxvidcore-dev libx264-dev -y
sudo apt-get install libgtk2.0-dev libgtk-3-dev -y
sudo apt-get install libatlas-base-dev gfortran -y
sudo apt-get install python3 python3-setuptools python3-dev -y
sudo pip3 install numpy
Upvotes: 2
Reputation: 81
You can install opencv-python in raspberry with the following commands:
pip3 install opencv-python
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev
sudo apt-get install libqtgui4
sudo apt-get install python3-pyqt5
sudo apt install libqt4-test
Upvotes: 8
Reputation: 637
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.
Upvotes: 1