9

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

6 Answers 6

12

Use this:

sudo apt install libqt4-test

Reference:

Sign up to request clarification or add additional context in comments.

Comments

8

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

1 Comment

Worked like a treat, thanks! I had to use pip3 install opencv-python==3.4.6.27 though because the latest version of opencv is apparently incompatible with Raspberry Pi at the moment.
2

Here are the steps to solve your problem

  1. First uninstall opencv-python

sudo pip3 uninstall opencv-python

` 2. install opencv using the CMake

  1. Install CMAKE developer packages

sudo apt-get install build-essential cmake pkg-config -y

  1. Install Image I/O packages

sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev -y

  1. Install Video I/O packages

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y

sudo apt-get install libxvidcore-dev libx264-dev -y

  1. Install the GTK development library for basic GUI windows

sudo apt-get install libgtk2.0-dev libgtk-3-dev -y

  1. Install optimization packages (improved matrix operations for OpenCV)

sudo apt-get install libatlas-base-dev gfortran -y

  1. Install Python 3 and numpy

sudo apt-get install python3 python3-setuptools python3-dev -y

sudo pip3 install numpy

  1. follow this link for more details HOW TO INSTALL OPENCV 3.4.0 WITH PYTHON 3 ON RASPBERRY PI 3

Comments

1

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.

Comments

-1

pip install opencv-python==3.3.0.10

Comments

-1

Try :

sudo apt-get install libQtTest-dev

thanks.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.