I have tried to compile OpenCV 3.2 onto my pi Zero W Board running Stretch, and I'm using a 16GB SD Card (that is running SSH on Mac and Python 2.7).

Running make to compile openCV takes over 9 hours to get to 83% at which point it just freezes (gets stuck) with no further progress. I am sure of this as I have left it for a good half hour and still no progress. I left it overnight the first time and got the error: connection to host [my ip]: broken pipe". But that takes a good hour or so to display that. It just seems to hang at 83% with no error or indication, and it's happened both times I have tried all the installation processes from the beginning (By deleting the openCV folder completely in VNC) and starting again. Even when I try to continue the build by changing to the build directory on the Pi, it continues from where it left off (at 83%) but gets stuck at the same point. Based on a lot of deep searching on Google, I have tried the following:

  • Deleted wolfram and Libre Office from the pi to free up 1GB of space on the pi. (so it is not a memory issue, it currently has 6GB free). I have run the free command and got the following:

total Mem: 493252 Swap: 102396 used Mem: 76112 Swap: 476

  • Adjusted the GPU_mem to 16 so I could maximize ram usage. Doing this, I noticed my swap memory usage increased from 0 to 476 (above) when trying to run make from 83% again. Not sure if that's a good thing..is this the best setting?
  • I noticed that I had the camera plugged into the pi during the whole process, which seemed to be the issue for some people, and tried again without the camera plugged in, but no luck. I further checked config.txt to ensure x=0, not x=1, to ensure the camera is not enabled and GPU is set at 16.

Does anybody have any ideas about what could be causing this and why it's not completing the build, and how I could fix this? There's not much on the internet. It's just from what I was able to get from online forums and comments. I've been stuck on this for a few days now, and I need to get it working for my uni project, and it is so frustrating :( I am a beginner at using the raspberry pi. Any help would be greatly appreciated!

The build gets stuck at the following line: [ 83%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o

Thanks in advance Amir

  • I haven't checked for Stretch, but for earlier versions of Raspian, you could get pre-compiled openCV. Any reason not to do that instead?
    – Brick
    Dec 31, 2017 at 15:16

1 Answer 1


You should increase your swap.

My install was getting stuck as well until I increased my swap. Then it completed. You could try temporarily doing that to see if it helps.


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.