Face Rec Not working

Im using a Pi 4 2GB model and trying to use the new face rec guide. BUT when I do this command: pip install face-recognition, it just gives me errors. Anyone know why?

Hi @Ethan298285,

Welcome to the forum!

Could you share a screenshot of the errors you’re seeing? Do they come up right away, or only after some time? That’ll help us narrow down what’s going on.

That said, the face-recognition library relies on dlib, which can be quite heavy to compile—especially on a Raspberry Pi 4 with 2GB RAM. This often leads to build failures due to limited memory.

A quick fix that may help:

Temporarily increase the swap file size. This gives your Pi more virtual memory to work with during the build.

Here’s how to do it:

sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=1024/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon

Once you’ve done that, try installing again:

pip3 install face-recognition

After installation, it’s a good idea to set the swap size back to 100MB to avoid long-term performance issues.

If the project is critical and ongoing, a Pi 4 with 4GB or 8GB RAM—or even a Pi 5—will make a noticeable difference.

The face-recognition library depends on:

  • dlib (which requires CMake and compiles C++ code)
  • cmake, boost, numpy, etc.

On a Raspberry Pi, especially with limited RAM, building dlib can easily fail unless everything is prepped correctly.

1 Like