1

I have installed OpenCv on my Raspberry pi Model 3B. It is working for python 2.7 but not for python 3
The error im getting is:

pi@raspberrypi:~ $ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import cv2
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/.local/lib/python3.7/site-packages/cv2/init.py", line 3, in < module>
from .cv2 import *
ImportError: /home/pi/.local/lib/python3.7/site-packages/cv2/cv2.cpython-37m-arm-l inux-gnueabihf.so: undefined symbol: __atomic_fetch_add_8

EDIT :
I tried using cmake: according to https://answers.opencv.org/question/215735/make-error-__atomic_fetch_add_8-on-raspberrypi4/

I am getting the followin error:
pi@raspberrypi:~ $ cmake -DCMAKE_BUILD_TYPE=Release \

-DCMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=${HOME}/opencv_contrib-${OPENCV_VERSION}/m odules \
-D ENABLE_VFPV3=ON \
-D ENABLE_NEON=ON \
-D BUILD_TESTS=OFF \
-D WITH_TBB=OFF
CMake Warning:
No source or binary directory provided. Both will be assumed to be the same as the current working directory, but note that this warning will become a fatal error in future CMake releases.

CMake Error: The source directory "/home/pi" does not appear to contain C MakeLists.txt.

EDIT :

installed opencv-python=4.1.0.25 and it worked using pip install opencv-python=4.1.0.25

2

There's a known issue with the opencv wheels on piwheels. You need to preload python3 with:

LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1 python3

See post here: https://blog.piwheels.org/new-opencv-builds-including-opencv-4-x/ and follow the issue here: https://github.com/piwheels/packages/issues/59

| improve this answer | |
  • tried it i am getting bash command not found error – apurva_b Feb 28 at 12:27
  • thank you for the sites they did help me! – apurva_b Feb 28 at 13:21
  • 1
    @apurva_b Because the answer helped you it would be nice if you could accept the 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 2 at 13:04

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.