`I tried installing opencv on my raspi 3B using pip, on trying to import cv2 i am getting an error Attempt to install opencv on raspi 3B model with raspbian Buster Edit: code lines:

Successfully installed opencv-python-

`(cv) pi@raspberrypi:~ $ workon cv
(cv) pi@raspberrypi:~ $ python

import cv2
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/cv2/init.py", l ine 3, in
from .cv2 import *
ImportError: libQtGui.so.4: cannot open shared object file: No such file or dire ctory`

import cv2 is working
There was a library missing: sudo apt-install libQtGui4 worked for me

  • 4
    Please don't post pictures of text. It's unreadable. Instead paste the text direct into the question.
    – Ingo
    Feb 26, 2020 at 20:59

1 Answer 1


The reason you cannot access opencv in your virtualenv is because you have installed opencv in your system python environment. Each virtualenv keeps its packages separate from other vitualenvs and the system python. You can see the list of pacakges available from within each environment by pip list

To access opencv in your vitualenv:

workon cv
pip install opencv-python
  • i tried that as well, didnt help.
    – apurva_b
    Feb 27, 2020 at 12:42
  • what is the output of pip list when you are in your virtual env?
    – justinjt
    Mar 1, 2020 at 19:20

Your Answer

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

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