face_recognition icon indicating copy to clipboard operation
face_recognition copied to clipboard

ModuleNotFoundError: No module named 'face_recognition'

Open devupkim opened this issue 5 years ago • 36 comments

  • 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??

devupkim avatar Dec 25 '19 17:12 devupkim

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

bashanyy avatar Dec 30 '19 06:12 bashanyy

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

leeadh avatar Jan 04 '20 11:01 leeadh

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

devupkim avatar Jan 04 '20 14:01 devupkim

Same issue

danaki avatar Feb 05 '20 14:02 danaki

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

yathartharora avatar Feb 21 '20 06:02 yathartharora

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.

Alamnoor avatar Feb 25 '20 08:02 Alamnoor

Hi Alamnoor,

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

Please help.

Benito2204 avatar Mar 23 '20 20:03 Benito2204

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

Alamnoor avatar Mar 24 '20 06:03 Alamnoor

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.

Benito2204 avatar Mar 25 '20 15:03 Benito2204

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

Alamnoor avatar Mar 26 '20 10:03 Alamnoor

Hi Alamnoor,

Sorry for the late reply.

This is my email address- [email protected]

Once you drop an email I’ll send you my contact details.

Thanks Benito

On Thu, Mar 26, 2020 at 6:34 AM Alamnoor [email protected] wrote:

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ageitgey/face_recognition/issues/1016#issuecomment-604352797, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOQCY5LUVOH3RCKA24NRECTRJMVU5ANCNFSM4J7FZLQA .

Benito2204 avatar Mar 28 '20 15:03 Benito2204

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.

AlirezaParchami avatar Apr 10 '20 06:04 AlirezaParchami

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

Amir-ESH avatar Apr 12 '20 08:04 Amir-ESH

same issue No module named 'face_recognition'

AjayChouhanSingh avatar Apr 12 '20 19:04 AjayChouhanSingh

How to install window?

Vào 02:02 AM, T.2, 13 Th4, 2020 Ajay Singh Chouhan [email protected] đã viết:

same issue No module named 'face_recognition'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ageitgey/face_recognition/issues/1016#issuecomment-612661057, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN5DG3MW6ZELXMGAHCQ4L7TRMIF25ANCNFSM4J7FZLQA .

thoangnguyen1308 avatar Apr 13 '20 18:04 thoangnguyen1308

same issue

Chang-Xu-CC avatar May 04 '20 00:05 Chang-Xu-CC

how to install face_recognition lib in conda env

fairoz-khan avatar May 14 '20 11:05 fairoz-khan

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.

mohdvais avatar May 29 '20 06:05 mohdvais

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

nirajmalpani avatar Jun 16 '20 07:06 nirajmalpani

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 )

NusriNalir avatar Jul 17 '20 09:07 NusriNalir

Still same issue

Antu7 avatar Jul 23 '20 03:07 Antu7

Still same issue

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

NusriNalir avatar Jul 23 '20 14:07 NusriNalir

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

Thanks @Alamnoor

SomaNibe avatar Jul 29 '20 11:07 SomaNibe

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

ocristopfer avatar Oct 07 '20 13:10 ocristopfer

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

yzzzd avatar Jan 14 '21 09:01 yzzzd

pip3.8 install face_recognition

this worked for me, thanks.

MahmoudG-Kotp avatar May 23 '21 07:05 MahmoudG-Kotp

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

yashpawar249 avatar Jan 19 '22 15:01 yashpawar249

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.

Mablung avatar May 21 '22 17:05 Mablung

pip3.8 install face_recognition

this worked for me, many thanks

mzaenuddin avatar Jul 27 '22 04:07 mzaenuddin

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

jmcausing avatar Sep 23 '22 09:09 jmcausing