Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'face_recognition' #1016

Open
devupkim opened this issue Dec 25, 2019 · 33 comments
Open

ModuleNotFoundError: No module named 'face_recognition' #1016

devupkim opened this issue Dec 25, 2019 · 33 comments

Comments

@devupkim
Copy link

devupkim commented Dec 25, 2019

  • face_recognition version: 1.2.3
  • Python version: 3.7.4
  • Operating System: windows 10

Description

I have a problem with Run the file of facerec from webcam faster
so I referenced #407 issue and I revised code like
'import face_recognition' to 'from face_recognition_cli import face_recognition'


before I revised the code just like

import face_recognition

There was traceback message like this

PS C:\Users\puppy> & C:/Users/puppy/Anaconda3/python.exe c:/Tensorflow1/face/Untitled-1.py
Traceback (most recent call last):
File "c:/Tensorflow1/face/Untitled-1.py", line 1, in
import face_recognition
ModuleNotFoundError: No module named 'face_recognition'

What I Did

and I ran, there was traceback message like this

PS C:\Users\puppy> & C:/Users/puppy/Anaconda3/python.exe c:/Tensorflow1/face/Untitled-1.py
Traceback (most recent call last):
  File "c:/Tensorflow1/face/Untitled-1.py", line 1, in <module>
    from face_recognition_cli import face_recognition
  File "c:\Tensorflow1\face\face_recognition_cli.py", line 6, in <module>
    import face_recognition.api as face_recognition
ModuleNotFoundError: No module named 'face_recognition'

what should I do??

@bashanyy
Copy link

why not you 'pip install face_recognition'? and you dirname can't named face_recognition.

@leeadh
Copy link

leeadh commented Jan 4, 2020

Did u managed to solve this? I have the same issue @TaeHyunKim11

@devupkim
Copy link
Author

devupkim commented Jan 4, 2020

No, I didn't. :<
I already done install face_recognition

@danaki
Copy link

danaki commented Feb 5, 2020

Same issue

@yathartharora
Copy link

I am facing the same issue ..Can you please help me with it

@Alamnoor
Copy link

Alamnoor commented Feb 25, 2020

Step1: pip install cmake
Step2: pip install dlib
Step3: pip install face_recognition
it worked for me...
But install it in specific environment that will be used later for face_recognition code.

@Benito2204
Copy link

Hi Alamnoor,

I installed all the three which you have mentioned but I am getting error no module named 'face_recognition'.

Please help.

@Alamnoor
Copy link

Hi Alamnoor,

I installed all the three which you have mentioned but I am getting error no module named 'face_recognition'.

Please help.

Have you installed it in environment from where you are running your code?
Mean:
Step 1: Open " anaconda navigator"
Step 2: Go to Environments and select required environment where you have installed face_recognition library i,e ( base (root), or you have another environments). Or you can create environment and then install this package there).
Step 3: Open "idle", or Jupyter notebook", or python shell from the current environment. Then check it. Thanks
You can feel free to contact me again. Thanks

@Benito2204
Copy link

Hi Alamnoor,

Thanks for your prompt response.

I couldn't see face_recognition library in the environment but I am sure that I installed cmake, dlib, and face_recognition.

I still getting no module error.

I have been trying since 3 days but I couldn't find the solution.

@Alamnoor
Copy link

Hi Alamnoor,

Thanks for your prompt response.

I couldn't see face_recognition library in the environment but I am sure that I installed cmake, dlib, and face_recognition.

I still getting no module error.

I have been trying since 3 days but I couldn't find the solution.

Can we use a platform where we will discuss it in live? After solution, we will put it here for other users. Please let me know. It should be work with above dependency. Thanks

@Benito2204
Copy link

Benito2204 commented Mar 28, 2020 via email

@AlirezaParchami
Copy link

Try not to use precompiled dlib library and try to install and compile it exclusively on your device.

You need dlib to use face_recognition library. To install and build dlib on your system, you have to have Visual Studio 2015 or newer.

As I had VS 2013, I could not install and build dlib. Therefore, I decided to install a precompiled version of dlib (.whl files). Although it was installed successfully, I had the same problem and I got the error:
ModuleNotFoundError: No module named 'face_recognition'

I managed to solve this problem by installing VS2015 and cmake. With "pip install dlib", the dlib library was installed and compiled exclusively on my system and after that with "pip install face-recognition" the library was installed and detected successfully.

@Amir-ESH
Copy link

My problem fixed with this way:
Install Cmake with:
sudo apt install cmake
after install cmake I installed face_recognition
pip3.8 install face_recognition

@AjayChouhanSingh
Copy link

same issue
No module named 'face_recognition'

@thoangnguyen1308
Copy link

thoangnguyen1308 commented Apr 13, 2020 via email

@Chang-Xu-CC
Copy link

same issue

@fairoz-khan
Copy link

how to install face_recognition lib in conda env

@mohdvais
Copy link

Running setup.py install for face-recognition-models ... done
Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\abc\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib\setup.py'"'"'; file='"'"'C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\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 'C:\Users\abc\AppData\Local\Temp\pip-record-jxq_vg6c\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib
Complete output (80 lines):
running install
running build
running build_py
package init file 'dlib_init_.py' not found (or not a regular file)
running build_ext
Building extension for Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)]
Invoking CMake setup: 'cmake C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib\build\lib.win32-3.8 -DPYTHON_EXECUTABLE=c:\users\abc\appdata\local\programs\python\python38-32\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib\build\lib.win32-3.8'
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
The CMAKE_C_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  To use the NMake generator with Visual C++, cmake must be run from a shell
  that can use the compiler cl from the command line.  This environment is
  unable to invoke the cl compiler.  To fix this problem, run cmake from the
  Visual Studio Command Prompt (vcvarsall.bat).

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:3 (project):
  The CMAKE_CXX_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  To use the NMake generator with Visual C++, cmake must be run from a shell
  that can use the compiler cl from the command line.  This environment is
  unable to invoke the cl compiler.  To fix this problem, run cmake from the
  Visual Studio Command Prompt (vcvarsall.bat).

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "C:/Users/abc/AppData/Local/Temp/pip-install-3fadg9h2/dlib/build/temp.win32-3.8/Release/CMakeFiles/CMakeOutput.log".
See also "C:/Users/abc/AppData/Local/Temp/pip-install-3fadg9h2/dlib/build/temp.win32-3.8/Release/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib\setup.py", line 223, in <module>
    setup(
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\install.py", line 61, in run
    return orig.install.run(self)
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\command\install.py", line 545, in run
    self.run_command('build')
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib\setup.py", line 135, in run
    self.build_extension(ext)
  File "C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib\setup.py", line 172, in build_extension
    subprocess.check_call(cmake_setup, cwd=build_folder)
  File "c:\users\abc\appdata\local\programs\python\python38-32\lib\subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\abc\\AppData\\Local\\Temp\\pip-install-3fadg9h2\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\abc\\AppData\\Local\\Temp\\pip-install-3fadg9h2\\dlib\\build\\lib.win32-3.8', '-DPYTHON_EXECUTABLE=c:\\users\\abc\\appdata\\local\\programs\\python\\python38-32\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\abc\\AppData\\Local\\Temp\\pip-install-3fadg9h2\\dlib\\build\\lib.win32-3.8']' returned non-zero exit status 1.
----------------------------------------

ERROR: Command errored out with exit status 1: 'c:\users\abc\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\dlib\setup.py'"'"'; file='"'"'C:\Users\abc\AppData\Local\Temp\pip-install-3fadg9h2\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 'C:\Users\abc\AppData\Local\Temp\pip-record-jxq_vg6c\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(opencv-env) C:\Users\abc>python -m pip install --upgrade pip
Requirement already up-to-date: pip in c:\users\abc\anaconda3\envs\opencv-env\lib\site-packages (20.1.1)

(opencv-env) C:\Users\abc>pip install dlib
Collecting dlib
Using cached dlib-19.19.0.tar.gz (3.2 MB)
Building wheels for collected packages: dlib
Building wheel for dlib (setup.py) ... error

in my system, the problem occurs again and again which is mention above dlib problem and I already create a virtual environment, please help me.

@nirajmalpani
Copy link

First make sure u have Visual studio code installed.
then run the following commands
pip install cmake
pip install dlib
pip install face_recognition

@NusriNalir
Copy link

if you have already installed dlib and face_recognition, 1st uninstall them by pip uninstall.
then make sure you have cmake installed. you can do that by
cmake –version
if not install cmake.
after that install dlib by conda. this way it will make sure you have all the dependencies installed.
conda install -c conda-forge dlib
then install face_recognition again by
pip install face_recognition

this will solve the issue. (worked for me )

@Antu7
Copy link

Antu7 commented Jul 23, 2020

Still same issue

@NusriNalir
Copy link

Still same issue

Here the trick is having installed "cmake" properly. can you check whether you have installed it correctly?

@SomaNibe
Copy link

It worked for me. Just
Step1: pip install cmake
Step2: pip install dlib
Step3: pip install face_recognition

Thanks @Alamnoor

@ocristopfer
Copy link

A used this comands to install on windows.

//Crete conda env using python 3.6, dlib work on windows 32 bits using this version of anaconda repo
conda create -n facial python=3.6 -y
activate facial

//Instaling dblib from anaconda repo
conda install -c conda-forge dlib -y

pip install opencv-python
pip install Pillow
pip install imutils
pip install face_recognition_models
//Instal face_recognition withou deps, and it don't try install dlib.
pip install face_recognition --no-deps

@yzzzd
Copy link

yzzzd commented Jan 14, 2021

Just use pip work for me, I used pip3 before.

@MahmoudG-Kotp
Copy link

pip3.8 install face_recognition

this worked for me, thanks.

@yashpawar249
Copy link

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\Face_Recognition_Project-main\Face_Recognition_Project-main> & "C:/Program Files/Python310/python.exe" d:/Face_Recognition_Project-main/Face_Recognition_Project-main/attendance.py
Traceback (most recent call last):
File "d:\Face_Recognition_Project-main\Face_Recognition_Project-main\attendance.py", line 3, in
import face_recognition
ModuleNotFoundError: No module named 'face_recognition'
PS D:\Face_Recognition_Project-main\Face_Recognition_Project-main>

such error i am facing plz try to solve

@Mablung
Copy link

Mablung commented May 21, 2022

Hello.

Click file (top left on the pane)
Click Settings ( Directly CTRL+ALT+S)

In settings click the button with the project name,click python interpreter

Click the + button in the window that opens

Search face-recognition on search panel and install it.

@mzaenuddin
Copy link

pip3.8 install face_recognition

this worked for me, many thanks

@jmcausing
Copy link

same issue!! It was working yesterday then I turned on my PC it's not working!!
image

@jmcausing
Copy link

Ok I think this is an issue with Windows Python interpreter
This screenshot shows the same error because I am using python3 which is not part of Scripts/ folder.
image

So python3 is part of overall Windows Python install and not in my virtual environment. But python.exe is part of my virtual environment
image

Running python (not python3) works fine
image

@mabdulrehmankhan
Copy link

Step1: pip install cmake
Step2: pip install dlib
Step3: pip install face_recognition

@Victorvikson1996
Copy link

➜ python my_flask.py

Traceback (most recent call last):
File "/Users/chukwuebuka/web/project2/backend/my_flask.py", line 3, in
from face import recognize_faces
File "/Users/chukwuebuka/web/project2/backend/face.py", line 1, in
import face_recognition
ModuleNotFoundError: No module named 'face_recognition'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests