Q:

How can I use OpenCV with Python 3 on a Raspberry Pi?

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.

A:

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.

