Installation of the face_recognition python library


The python face_recognition library has a ton of features. In our chat app, we are using it as the basis of our login system. Instead of a password, users will enter a username and consent that a photo will be taken of them with their computer’s webcam. The photo and their username will be stored in a database and that photo will be used to compare against new photos taken at future logins. We are really only scratching the surface of what the face_recognition library can do. 

Face_recognition depends on a large machine learning library called dlib. And dlib requires another library called CMake that controls the software compilation process, among other things. 

I installed these three packages, along with some other libraries, and everything was working. I was pretty sure I had downloaded some things I didn’t need, so I wasn’t sure what to put in the requirements.txt file. 

It turned out that in my selectiveness, I missed something important. When I made a new virtual environment and ran pip3 install -r requirements.txt, everything seemed great until I ran my code and got an error message: ModuleNotFoundError: No module named ‘face_recognition’. I googled the error and found that I was not alone. The consensus on the solution was to install cmake, then dlib, then face_recogntion. In that order. Then face_recognition should work. But it wasn’t working for me, and others online had the same problem! I was getting worried.

Thankfully, cooler heads prevailed and I walked through it with my partner. We downloaded packages one by one in a new virtual environment. When we were waiting for dlib to install, we noticed something:

It was installing a legacy version of setup.py for dlib because wheel is not installed. Wheel? Yes, I had downloaded wheel originally, because I had read about it somewhere random, but it doesn’t show up in pip freeze, so I wasn’t sure it needed to be in requirements.txt. The only thing I know about wheel is that it makes dependency installation easier, and that turned out to be true. Afterinstalling wheel and reinstalling dlib, the ModuleNotFound error went away. 

I did not see installing wheel as an answer to my problem anywhere on stackoverflow or github, so perhaps I should go spread the gospel.

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *