ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
52.47k stars 13.37k forks source link

ModuleNotFoundError: No module named 'face_recognition' #1016

Open devupkim opened 4 years ago

devupkim commented 4 years ago

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 commented 4 years ago

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

leeadh commented 4 years ago

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

devupkim commented 4 years ago

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

danaki commented 4 years ago

Same issue

yathartharora commented 4 years ago

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

Alamnoor commented 4 years ago

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 commented 4 years ago

Hi Alamnoor,

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

Please help.

Alamnoor commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Hi Alamnoor,

Sorry for the late reply.

This is my email address- antonya@uwindsor.ca

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

Thanks Benito

On Thu, Mar 26, 2020 at 6:34 AM Alamnoor notifications@github.com 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 .

AlirezaParchami commented 4 years ago

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

You need dlib to use _facerecognition 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 commented 4 years ago

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 commented 4 years ago

same issue No module named 'face_recognition'

thoangnguyen1308 commented 4 years ago

How to install window?

Vào 02:02 AM, T.2, 13 Th4, 2020 Ajay Singh Chouhan notifications@github.com đã 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 .

Chang-Xu-CC commented 4 years ago

same issue

fairoz-khan commented 4 years ago

how to install face_recognition lib in conda env

mohdvais commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

Still same issue

NusriNalir commented 3 years ago

Still same issue

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

SomaNibe commented 3 years ago

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

Thanks @Alamnoor

ocristopfer commented 3 years ago

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 commented 3 years ago

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

MahmoudG-Kotp commented 3 years ago

pip3.8 install face_recognition

this worked for me, thanks.

yashpawar249 commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

pip3.8 install face_recognition

this worked for me, many thanks

jmcausing commented 1 year ago

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

jmcausing commented 1 year ago

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 commented 9 months ago

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

Victorvikson1996 commented 2 months ago

➜ 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'