ModuleNotFoundError: No module named 'face_recognition'
Asked Answered
Y

5

7
import face_recognition

image = face_recognition.load_image_file("My_Image.png")
face_locations = face_recognition.face_locations(image)
print("I found {} face(s) in this photograph.".format(len(face_locations)

When I run above code, I've found following error message.

Traceback (most recent call last): File "sample.py", line 1, in import face_recognition

And I've checked that I've found following error message when I've installed face_recognition library.

pip install face_recognition

  RuntimeError:
  *******************************************************************
   CMake must be installed to build the following extensions: dlib
  *******************************************************************


  ----------------------------------------
  Failed building wheel for dlib
  Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib, Pillow, numpy, face-recognition-models, face-recognition

Command "/usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;file='/private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-install-gk35rom0/dlib/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-record-3enjhgfq/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-install-gk35rom0/dlib/

My python version is Python 3.7.1 and pip is pip 19.0.3 from /Library/Python/2.7/site-packages/pip (python 2.7)

Yore answered 14/3, 2019 at 3:12 Comment(2)
Is Cmake installed? Also I am assuming Ubuntu?Jelle
Install Cmake then do pip3 install face_recognitionCherenkov
C
9

Install Cmake with:

sudo apt install cmake

And for python3 don't use pip alone, use pip3 to install future python3 modules:

pip3 install face_recognition

Cherenkov answered 14/3, 2019 at 3:24 Comment(3)
still not working even I've installed cmake and pip3 install face_recognitionYore
got it, there is credential required to install pip3 install face_recognition.Yore
facing similar kind of problem, Please can you share complete stepsTapley
S
4

I was facing same issue, but then it solved through following steps:

Step 1: Download Microsoft Visual Studio 2015 or newer (check if build tools are enough).

Step 2: Download cmake (pip install cmake)

Step 3: Install dlib (pip install dlib)

Step 4: Install face-recognition (pip install face-recognition)

But install it in specific environment that will be used later for face_recognition code (In conda: activate environment name).

Reference: https://www.youtube.com/watch?v=oSQAXMgwLFo

Schroder answered 10/4, 2020 at 14:28 Comment(0)
P
1

For everyone who still found error when installing this step, I will give a brief requirements for your system.

  1. Python3.9 [the most important]
  2. Download dlib (this)

Next, after the above requirement fulfilled, do this.

  1. pip install cmake
  2. pip install dlib-19.23.0-cp39-cp39-win_amd64.whl
  3. pip install opencv-python
  4. pip install face_recognition

Bonus, in my case, I got error with the pillow library so you need to reinstall it, using these steps.

  1. pip uninstall pillow
  2. pip install Pillow

Well, I hope this will help, thanks.

Prepuce answered 16/8, 2022 at 14:48 Comment(0)
T
0

This worked for me...

pip install CMake==3.22.2
pip install dlib==19.18.0
pip install face_recognition
Tumefy answered 6/12, 2022 at 22:58 Comment(0)
A
0

First, you need to have CMake installed on your system.

brew install cmake
cmake --version
# cmake version 3.30.3

# this because it will takes some time
pip install face-recognition --verbose 
Atalanti answered 4/9, 2024 at 5:24 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.