I followed a tutorial online for installing opencv4 on raspberry pi. Everything works except when trying to create a symbolic link to my cv2.so.
It appears to be working but I can only import cv2 module inside the /usr/local/python/cv2/python-3.7 directory if I'm outside, I get the :

ModuleNotFindError" no module named "cv2"
  • Did you check this link out? – M. Rostami Mar 22 at 15:08
  • A Python module is more than just a shared library, there's also an __init__.py file and some config and loader files. Manually linking to the shared library is the wrong approach. The name of the shared library is also wrong, it should contain the Python version and the architecture, for example: /usr/local/lib/python3.8/site-packages/cv2/python-3.8/cv2.cpython-38-aarch64-linux-gnu.so. Usually, if you compile OpenCV from source and then make install, it is installed correctly as a Python module, why are you doing it manually? Please link to the tutorial you followed. – tttapa Mar 22 at 15:22
  • I don't have site-packages only "dist-packages": /usr/local/lib/python3.7/dist-packages $ ls pip pip-20.0.2.dist-info the tutorial: pyimagesearch.com/2018/09/26/… – Kungbjucha Mar 23 at 6:48

I "Fixed" it by creating an virtual environment for opencv.

| improve this answer | |
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Mar 30 at 12:39

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.