I followed https://medium.com/@patrick_ryan/building-opencv-4-10-on-raspian-buster-and-raspberry-pi4-64669bd2eb74 to install open-cv on my raspberry pi.

On using the make -j4 command it took approx 2 hours to reach till 100% but after that the process never completed. I restarted the pie again and ran the same command but still, it gets stuck at 100%. What should I do?Sreenshot of my terminal

  • 2
    Please don't post pictures of text. Instead paste the text output direct into the question.
    – Ingo
    Commented Sep 8, 2019 at 10:49
  • The link you have given is wrong.
    – Ingo
    Commented Sep 8, 2019 at 10:57
  • This is the link. medium.com/@patrick_ryan/… Commented Sep 8, 2019 at 19:15
  • Please edit your question and correct the link there. And please take the short Tour and visit the Help Center to get an idea how things work here.
    – Ingo
    Commented Sep 8, 2019 at 22:50
  • I have down voted the question because the important link is still wrong.
    – Ingo
    Commented Sep 27, 2019 at 17:36

4 Answers 4


You don't tell us why do you want to compile OpenCV from source so I assume it is not necessary. We have seen many problems on this site doing it. You also try to compile for python version 2. This is nowadays only used for backward compatibility. It is strongly recommended to use up to date python3.

OpenCV is part of the default raspbian repository. Just installing it with apt works out of the box. How to do it you can look at Pre-Built openCV on raspbian Buster.

  • I have to use open cv in my Geany Editor using C++. Am able to import cv2 in python and no error is shown. But how do I set the OpenCv path for my Geany. Because the tutorial which am following is showing multiple include files which are not present in my open cv folder. Commented Sep 8, 2019 at 19:06
  • @NiteshSingh Please edit your question and add the additional information from the comment to it.
    – Ingo
    Commented Sep 8, 2019 at 22:52

If the build process doesn't throw an error and keeps the CPU busy, I'd assume it's still working. I never tried to build OpenCV, but 2 hours doesn't seem like an extraordinary time. Building Firefox on an RPi 4 takes more than that.

If you didn't install any cooling, a thermally throttled CPU can take days to build something substantial. Running at extreme temperatures will also damage the board sooner or later.

Since you have restarted the system while a build was in progress, I'd recommend cleaning it up (make clean, or just scrap the whole folder and start from scratch) before you re-attempt a build.


Sorry, I couldn't follow the link. Compiling OpenCV from source may run into swap file limits. Check the value of the CONF_SWAPFILE in the file /etc/dphys-swapfile. You may want to increase it because the default Raspbian Buster setting (as before) is 100.

  • This is the link. medium.com/@patrick_ryan/… Commented Sep 8, 2019 at 19:14
  • I already changed the swap file limit to 2048 as advised in the link Commented Sep 8, 2019 at 19:15
  • I'm pretty sure that a compiler running out of RAM will crash rather than being stuck at 100% CPU load. Commented Sep 18, 2019 at 7:36

It can be difficult installing opencv on raspberry pi. A couple suggestions:

1) Use make instead of make -j4.

2) If suggestion 1 doesn't get you passes the ram stall; Try building with different opecv version. I generally get better results on the RPI when building with versions 3.4.

3) Make sure swap ram is configured properly. Adjusting the Swappiness could also help.

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.