I have installed OpenCV and and access it with Python 2. However, I'm unable to use OpenCV with Python 3.

It says "Cannot open shared object".

ImportError: libQTtest.so.4: cannot open shared object file: no such file or directory

I have tried sudo cat /usr/local/lib and some other commands but I still can't get it to work.

How do I share OpenCV with Python 3 on a Raspberry Pi 3 B+?

I have also tried following the steps at https://github.com/cmusphinx/pocketsphinx-python/issues/6 and I have read this.

  • How did you install OpenCV and the Python bindings? Did you just use apt-get install python-opencv? It'd also be helpful if you could rerun the code and get the exact, full error message you get rather than just the "Cannot open shared object" bit. – Aurora0001 May 6 '18 at 15:35
  • libqtgui.so.4 cant be shared is the error message and also i did it with cmake thing – JohnConstantine May 6 '18 at 16:44
  • 1
    Try running sudo apt install libqtgui4 and then try again, @John. Let me know if you have any luck. – Aurora0001 May 6 '18 at 17:03
  • @JohnConstantine , see this tutorial on installing opencv on stretch for python 2 or 3. – scitronboy May 6 '18 at 17:04
  • What on earth is sudo cat /usr/local/lib supposed to accomplish, lol? It's gobbledygook, kind of like, "I put the car windows in reverse, but the steering wheel still won't open". Sorry, but you need to go into much more detail about exactly what you've done vis., "I installed..." and exactly when and what errors you are getting if you want someone else to troubleshoot this. – goldilocks May 6 '18 at 18:25

It says "Cannot open shared object".

ImportError:libQTtest.so.4:cannot open shared object file:no such file or directory

Yes, but it does not say this is because "the library isnt shared with it". What it says is, "no such file or directory".

As far as I can tell, libQTtest.so.4 is not actually part of openCV, although it is part of a GUI framework upon which openCV may depend.

According to the Debian package search (Raspbian is more or less Debian with some minor tweaks), this .so is part of package libqt4-test, which is available in the Debian current stable version, 9 ("stretch"), armhf compilation, so should be in Raspbian. You can install this with:

sudo apt install libqt4-test

This may drag in some other dependencies. Note if you are using a previous version of Raspbian it probably is not available.

  • Thank you @goldilocks your command is work form me in : 1. raspberry pi 3 model B 2. python 3 3. opencv 3.4 4. os raspbian stretch 2018-10-09 – panji19 Oct 31 '18 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.