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

Windows Installation Tutorial #175

Closed
masoudr opened this issue Sep 14, 2017 · 236 comments
Closed

Windows Installation Tutorial #175

masoudr opened this issue Sep 14, 2017 · 236 comments

Comments

@masoudr
Copy link

@masoudr masoudr commented Sep 14, 2017

Hi,
I've successfully installed and tested this tool on my Windows 10 machine and I'm writing a simple procedure to install it. It may be useful for some people to try to use this tool on a Windows machine.

IMPORTANT: Actually this project has made for Linux systems and especially dlib. In my tests, the performance of this tool in Windows 10 was about a quarter in comparison with Ubuntu built with the same specs. But I haven't seen any difference between these two in other subjects.

Read First:
The new version of dlib doesn't need Boost anymore so you can skip it. Remember that you still need to meet the following requirements.
Requirments:
(I've used this tutorial with these tools installed on Windows 10 but the newer versions may work too.)

  1. Microsoft Visual Studio 2015 (or newer) with C/C++ Compiler installed. (Visual C++ 2015 Build Tools didn't work for me and I got into problems in compiling dlib)
  2. Of course Python3 (I used Python3.5 x64 but the other versions may work too)
  3. CMake for windows and add it to your system environment variables.
  4. (ONLY FOR older versions of dlib) Boost library version 1.63 or newer. Also, you can use precompiled binaries for specific MSVC you have but I don't suggest. (I've included the compiling procedure of Boost in this tutorial)

Installation:
Easy installation:
Just install dlib and face_recognition (not always on the newest version):
pip install dlib and then pip install face_recognition.

Manual installation:

  1. Download and install scipy and numpy+mkl (must be mkl version) packages from this link (all credits goes to Christoph Gohlke). Remember to grab the correct version based on your current Python version.
  2. Download Boost library source code or binary release for your current MSVC from this link.
  3. If you downloaded the binary version skip to step 4 else follow these steps to compile and build Boost by yourself:
    3-1. Extract the Boost source files into C:\local\boost_1_XX_X (X means the current version of Boost you have)
    3-2. Create a system variable with these parameters:
    Name: VS140COMNTOOLS
    Value: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\ (or any path where you have installed MSVC)
    3-3. Open Developer Command Prompt for Visual Studio and go to the current directory of Boost extracted and try these commands to compile Boost:
    bootstrap
    b2 -a --with-python address-model=64 toolset=msvc runtime-link=static
    3-4. If you successfully compile Boost, it should create compiled files in stage directory.
  4. (If you have already compiled Boost skip this step) If you already download the binary release just extract the contents to C:\local\boost_1_XX_X
  5. Grab latest version of dlib from this repo and extract it.
  6. Go to dlib directory and open cmd and follow these commands to build dlib: (remember to replace XX with the current version of Boost you have)
    set BOOST_ROOT=C:\local\boost_X_XX_X
    set BOOST_LIBRARYDIR=C:\local\boost_X_XX_X\stage\lib
    python setup.py install --yes USE_AVX_INSTRUCTIONS or python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
  7. Now you can use import dlib without any problem in your python script.
  8. You can also check the current version of dlib with pip show dlib.
  9. Now simply install face_recognition with pip install face_recognition.
  10. Enjoy!

Finally, I need to say thanks to @ageitgey and @davisking for their awesome work.

@TheDogeOfTheInternet
Copy link

@TheDogeOfTheInternet TheDogeOfTheInternet commented Sep 14, 2017

You don't need to manually install dlib. I was able to install it with pip (through the pip install face_recognition command) after I had Boost and CMake installed.

Which leads me to my second point; your tutorial does not mention CMake at all. I have no idea what CMake actually does, so it may not be required, but if it does have something to do with simplifying the install process, you should add it to your tutorial.

@masoudr
Copy link
Author

@masoudr masoudr commented Sep 14, 2017

@TheDogeOfTheInternet yes you are right the CMake is a must and I forgot to add it but it is just used to compile dlib and Boost. I've edited my post and add it thanks.
And for your first question yes you can use pip to install it but the latest versions are always on his Github repository and website so you need to compile it by yourself. Also, you can configure your compilation.

@ageitgey
Copy link
Owner

@ageitgey ageitgey commented Sep 17, 2017

Thanks @masoudr! I'll link it from the README.

@ageitgey ageitgey closed this Sep 17, 2017
@PBShortStop
Copy link

@PBShortStop PBShortStop commented Sep 19, 2017

hello @masoudr, i want to know CMake install procedure. Thanks.

@masoudr
Copy link
Author

@masoudr masoudr commented Sep 19, 2017

@PBShortStop Installation of CMake in windows is very simple just grab the installation file (*.msi) from this link and install it. Remember to check the "Add CMake to system path" during the installation. Then you can simply use cmake --version in command prompt.

@BachDoXuan
Copy link

@BachDoXuan BachDoXuan commented Sep 28, 2017

Dear all,
I've tried several times to build dlib, but waited more than 1 hour at face_recognition.cpp without seeing any progress. I redo it several times but still get stuck there. Can you help me with it?

@runt1m33rr0r
Copy link

@runt1m33rr0r runt1m33rr0r commented Sep 28, 2017

@BachDoXuan you need to use the visual studio 2015 compiler(msvc-14.0), 14.1 is bugged. You also need at least 2GB RAM, because face_recognition.cpp takes a lot of memory during compilation(which could be the reason it takes so long).

@BachDoXuan
Copy link

@BachDoXuan BachDoXuan commented Sep 28, 2017

I use VS CE 2017, 8GB RAM laptop. I use Windows 10 Pro but the windows is not activated. I have no idea what problem I have. Can you help me to install dlib?

@masoudr
Copy link
Author

@masoudr masoudr commented Sep 29, 2017

@BachDoXuan I used MSVC-14 and haven't tested the 2017 version. Are you using the precompiled version of Boost or compiling it by yourself?
Remember that some of the steps in this tutorial are for MSVC-14 and if you want to use with other versions you need to modify them.
Could you provide the error log?

@BachDoXuan
Copy link

@BachDoXuan BachDoXuan commented Sep 29, 2017

@masoudr @neutrinobomber Thank you very much for your helps. The screen doesn't have any error log. It just got stuck when building dlib at face_recognition.cpp, I waited for more than hour every time I got there. But currently when I use command "pip install face_recognition" directly, then it succeeds.

@masoudr
Copy link
Author

@masoudr masoudr commented Sep 29, 2017

@BachDoXuan You are right, you can always use pip to install this package without any further work on windows. This tutorial is for the people who wanted to build dlib from source or do some configurations to it.

@davisking
Copy link

@davisking davisking commented Sep 29, 2017

@loqpa
Copy link

@loqpa loqpa commented Oct 4, 2017

Hey! I have a problem while following this tutorial.
My versions are:
Python 3.5.4
dlib 19.7
boost 1.65.1
(using "with cuda" and "with avx" options)

jpeg.lib(jdatadst.c.obj) : error LNK2019: unresolved external symbol _imp_ferror referenced in function term_destination [C:\Users\Loqpa\Downloads\dlib-master\dlib-master\tools\python\build\dlib.vcxproj]
jpeg.lib(jmemmgr.c.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function vsscanf_l [C:\Users\Loqpa\Downloads\dlib-master\dlib-master\tools\python\build\dlib.vcxproj]
jpeg.lib(jmemansi.c.obj) : error LNK2019: unresolved external symbol imp_tmpfile referenced in function jpeg_open_backing_store [C:\Users\Loqpa\Downloads\dlib-master\dlib-master\tools\python\build\dlib.vcxproj]
C:\Users\Loqpa\Downloads\dlib-master\dlib-master\tools\python\build\Release\dlib.pyd : fatal error LNK1120: 3 unresolved externals [C:\Users\Loqpa\Downloads\dlib-master\dlib-master\tools\python\build\dlib
.vcxproj]

Any ideas how to fix it? I am up to trying everything you suggest:)

@masoudr
Copy link
Author

@masoudr masoudr commented Oct 4, 2017

@loqpa Hi,
Are you using a precompiled version of boost with MSVC14?
Try to add these system environment variables too:
VS110COMNTOOLS C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
VS120COMNTOOLS C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\
VS110COMNTOOLS C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
VSSDK140Install C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\
I don't know the exact cause of your problem but it seems that some of the library files are not recognized by dlib.

@loqpa
Copy link

@loqpa loqpa commented Oct 6, 2017

@masoudr Hello!
I am compiling boost by myself (following steps 3-1... 3-4) and my system environment variables were already set the way you suggested.
Tried with boost 1.63, got the same error.
Any other ideas?
By the way, i am using Anaconda python, in case it matters.

@masoudr
Copy link
Author

@masoudr masoudr commented Oct 6, 2017

@loqpa I used this method for the specified version of dependencies, so I am not sure if they work for other versions too.
As I know your problem is causing by missing some dll files on dlib's compile. I think you can try first submit your issue on dlib repository here, maybe @davisking have an answer to it and second use the exact procedure I mentioned here. I don't' know much about Anaconda try to exclude it.

@Klinsman21
Copy link

@Klinsman21 Klinsman21 commented Oct 7, 2017

Does anyone have the link to download, Microsoft Visual Studio 2015 with C / C ++ Compiler

@masoudr
Copy link
Author

@masoudr masoudr commented Oct 7, 2017

@Klinsman21 google is your friend :) try this.

@loqpa
Copy link

@loqpa loqpa commented Oct 7, 2017

@masoudr what dlib version did you use? I can use precompiled version 19.4 without any problems but i am really curious about new(19.5+) cnn face_detector :)

@masoudr
Copy link
Author

@masoudr masoudr commented Oct 8, 2017

@loqpa If you compile dlib from the source you can always use the latest features and besides of that you can customize the compilation for specific configuration like disable/enable AVX instruction, CUDA feature, etc. I used v19.6 but newer versions would work too. You can find new features on dlib's website in here.

@cmlyldz
Copy link

@cmlyldz cmlyldz commented Oct 11, 2017

Can anybody help me ?
VC 2015
boost 1_65_1
dlib 19.7

libboost_python3-vc140-mt-s-1_65_1.lib(errors.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' [D:\DEV\dlib-master\tools\python\build\dlib_.vcxproj]
1 Warning(s)
1 Error(s)
Time Elapsed 00:04:35.66
error: cmake build failed!

@masoudr
Copy link
Author

@masoudr masoudr commented Oct 11, 2017

@cmlyldz You are trying to compile an X86 code on X64 compiler or vice-versa. Try to use VS2015 x86 Native Tools Command Prompt to compile dlib and remember that your python architecture must be same.

@cmlyldz
Copy link

@cmlyldz cmlyldz commented Oct 12, 2017

@masoudr Thanks for answer. The problem was my python but there is no problem thanks to you.

@hepingtao
Copy link

@hepingtao hepingtao commented Oct 13, 2017

@masoudr I have also encountered exactly the same problem as @cmlyldz . And I used VS2015 x86 Native Tools Command Prompt to compile dlib, but the problem didn't go.

@masoudr
Copy link
Author

@masoudr masoudr commented Oct 13, 2017

@hepingtao Please give me more information about the exact version of your tools like python version?

@cmlyldz
Copy link

@cmlyldz cmlyldz commented Oct 13, 2017

@hepingtao be careful while downloading scipy, numpy you have to download them x86 like others(if you want to use x86). Also python, boost and also dlib must compile on x86 also. If you did everything in an x86 compiler (or x64) there will be no error.

@008karan
Copy link

@008karan 008karan commented Oct 15, 2017

I have installed cmak and added to path but while installing dlib getting message to install cmak

@masoudr
Copy link
Author

@masoudr masoudr commented Oct 15, 2017

@008karan If your CMake is successfully added, you can use cmake --version in cmd to verify that. I'm not sure if the problem will exist but put your complete error log here.

@masoudr
Copy link
Author

@masoudr masoudr commented Apr 8, 2020

@Ronneey This topic is about how to install face_recognition in Python so you need to follow the above steps to install it.
The datetime is a built-in Python module so no need to install it.
Use pip install opencv-python openpyxl to install opencv and openpyxl.
Hope this helps.

@pandeng-001
Copy link

@pandeng-001 pandeng-001 commented Apr 10, 2020

QQ截图20200410095131
I install cmake, numpy,spicy,dlib,face_recognition sucessfully,but if I use 'import face_recognition',then python will return traceback ,such as
'Traceback (most recent call last):
File "人脸识别.py", line 1, in
import face_recognition
File "D:\爬虫\lib\site-packages\face_recognition_init_.py", line 7, in
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "D:\爬虫\lib\site-packages\face_recognition\api.py", line 20, in
pose_predictor_68_point = dlib.shape_predictor(predictor_68_point_model)
RuntimeError: Unable to open D:\爬虫\lib\site-packages\face_recognition_models\models\shape_predictor_68_face_landmarks.dat'
How I can do? @masoudr

@masoudr
Copy link
Author

@masoudr masoudr commented Apr 10, 2020

@pandeng-001 It seems an installation issue because the models haven't installed properly. Try to reinstall face_recognition with pip install --upgrade --force-reinstall face_recognition and if it didn't help grab models from here and put them in D:\爬虫\lib\site-packages\face_recognition_models\models.

@pandeng-001
Copy link

@pandeng-001 pandeng-001 commented Apr 10, 2020

Ok, my issue is resolved with your help,thank you so much @masoudr

@Snowball55
Copy link

@Snowball55 Snowball55 commented Apr 12, 2020

should i have to use Microsoft Visual Studio 2015? I'm used to Pyhchram. Add i had installed boost and cmake but i still can't install dlib.

Collecting face_recognition
Using cached face_recognition-1.3.0-py2.py3-none-any.whl (15 kB)
Requirement already satisfied: face-recognition-models>=0.3.0 in f:\01电脑软件\07python\lib\site-packages (from face_recognition) (0.3.0)
Requirement already satisfied: Click>=6.0 in f:\01电脑软件\07python\lib\site-packages (from face_recognition) (7.1.1)
Requirement already satisfied: numpy in f:\01电脑软件\07python\lib\site-packages (from face_recognition) (1.18.2)
Requirement already satisfied: Pillow in f:\01电脑软件\07python\lib\site-packages (from face_recognition) (7.1.1)
Collecting dlib>=19.7
Using cached dlib-19.19.0.tar.gz (3.2 MB)
Installing collected packages: dlib, face-recognition
Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1:
command: 'f:\01电脑软件\07python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\MARK1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib\setup.py'"'"'; file='"'"'C:\Users\MARK1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\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\MARK1.ZEN\AppData\Local\Temp\pip-record-nzpmqh1c\install-record.txt' --single-version-externally-managed --compile --install-headers 'f:\01电脑软件\07python\Include\dlib'
cwd: C:\Users\MARK
1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib
Complete output (57 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.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\MARK1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\MARK1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib\build\lib.win-amd64-3.7 -DPYTHON_EXECUTABLE=f:\01电脑软件\07python\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\MARK~1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib\build\lib.win-amd64-3.7 -A x64'
-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:3 (project):
Generator

    NMake Makefiles

  does not support platform specification, but platform

    x64

  was specified.


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/Mark.Zeng/AppData/Local/Temp/pip-install-tvvffw1b/dlib/build/temp.win-amd64-3.7/Release/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\MARK~1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib\setup.py", line 261, in <module>
    'Topic :: Software Development',
  File "f:\01电脑软件\07python\lib\site-packages\setuptools\__init__.py", line 144, in setup
    return distutils.core.setup(**attrs)
  File "f:\01电脑软件\07python\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "f:\01电脑软件\07python\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "f:\01电脑软件\07python\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "f:\01电脑软件\07python\lib\site-packages\setuptools\command\install.py", line 61, in run
    return orig.install.run(self)
  File "f:\01电脑软件\07python\lib\distutils\command\install.py", line 545, in run
    self.run_command('build')
  File "f:\01电脑软件\07python\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "f:\01电脑软件\07python\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "f:\01电脑软件\07python\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "f:\01电脑软件\07python\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "f:\01电脑软件\07python\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\MARK~1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib\setup.py", line 135, in run
    self.build_extension(ext)
  File "C:\Users\MARK~1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib\setup.py", line 172, in build_extension
    subprocess.check_call(cmake_setup, cwd=build_folder)
  File "f:\01电脑软件\07python\lib\subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\MARK~1.ZEN\\AppData\\Local\\Temp\\pip-install-tvvffw1b\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\MARK~1.ZEN\\AppData\\Local\\Temp\\pip-install-tvvffw1b\\dlib\\build\\lib.win-amd64-3.7', '-DPYTHON_EXECUTABLE=f:\\01电脑软件\\07python\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\MARK~1.ZEN\\AppData\\Local\\Temp\\pip-install-tvvffw1b\\dlib\\build\\lib.win-amd64-3.7', '-A', 'x64']' returned non-zero exit status 1.
----------------------------------------

ERROR: Command errored out with exit status 1: 'f:\01电脑软件\07python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\MARK1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\dlib\setup.py'"'"'; file='"'"'C:\Users\MARK1.ZEN\AppData\Local\Temp\pip-install-tvvffw1b\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\MARK~1.ZEN\AppData\Local\Temp\pip-record-nzpmqh1c\install-record.txt' --single-version-externally-managed --compile --install-headers 'f:\01电脑软件\07python\Include\dlib' Check the logs for full command output.

@masoudr
Copy link
Author

@masoudr masoudr commented Apr 12, 2020

@Snowball55 You would better go with the easy installation, but if you want to compile the source you will need MSVC but the version doesn't matter.
Anyway, it seems that your problem is using the wrong architecture, make sure that use the X64 version of the visual studio command prompt.

@progmars
Copy link

@progmars progmars commented May 7, 2020

I wanted to have totally independent installation in a separate folder, so that's what I did:

Went to https://www.python.org/downloads/windows/ and chose "Python 3.6.8 - Dec. 24, 2018" -> "Windows x86-64 embeddable zip file" and extracted its contents to my newly prepared python3 folder.

Why 3.6.8 and not the latest one? Because I found prebuilt dlib binaries for 3.6 and none for 3.8. So, I hoped to get it working without having to install CMake. Otherwise, without CMake dlib installation failed, of course.

After that, I downloaded get-pip and put it too into python3 folder:
https://bootstrap.pypa.io/get-pip.py

Embedded Python has an issue - it ignores PYTHONPATH variable. To fix this, it turned out I have to add paths to pth file or delete the file. I chose to delete it (in my custom script below).

Here's the full cmd script that "worked on my machine". You can save it (install-standalone-deps.cmd) and put near your prepared python3 folder where you extracted Python 3.6.8 and get-pip.py, and then execute it.

@echo off
setlocal EnableExtensions DisableDelayedExpansion

cd %cd%\python3
set PYTHONPATH=%cd%
set PATH=%PATH%;%PYTHONPATH%;%PYTHONPATH%\Scripts;%PYTHONPATH%\Lib\site-packages
echo Standalone Python installation configured in %PYTHONPATH%

rem disabling embedded env file that causes PYTHONPATH to be ignored
if exist python36._pth ren python36._pth python36._pth.save

rem pip itself
python get-pip.py

rem Some important dependencies
pip install opencv-python

rem Installing prebuilt dlib that won't ask for CMake                                                 
pip install https://files.pythonhosted.org/packages/0e/ce/f8a3cff33ac03a8219768f0694c5d703c8e037e6aba2e865f9bae22ed63c/dlib-19.8.1-cp36-cp36m-win_amd64.whl
rem Installing face_recognition                  
pip install face_recognition

echo If there are no red error messages, then everything is OK and you can start running face recognition projects now.

pause

endlocal

Then I created another script that prepares environment. Let's call it setenv-py.cmd

@echo off
setlocal EnableExtensions DisableDelayedExpansion

set PYTHONPATH=%cd%\python3
set PATH=%PATH%;%PYTHONPATH%;%PYTHONPATH%\Scripts;%PYTHONPATH%\Lib\site-packages
echo Standalone Python installation configured in %PYTHONPATH%

rem Keeping it open for running Python commands
cmd /k

Then I prepared folder_with_pictures with some face images and ran setenv-py.cmd and entered command:

face_detection  folder_with_pictures

It worked! I received face coordinates.

So, I guess, nothing needed CMake? Or maybe it was picked up by some other place on my machine (but then why dlib installation failed unless I downloaded prebuilt binary?)

@masoudr
Copy link
Author

@masoudr masoudr commented May 7, 2020

@progmars In your script, you are installing dlib from a wheel package so there is no compilation. The CMake needs for compiling dlib from the source.

@progmars
Copy link

@progmars progmars commented May 7, 2020

@masoudr Yeah, I guessed so. I just was afraid that some other dependency of face_recognition or deeper down the line would still require CMake and my idea would fail, but fortunately enough, it worked.

@christopherpross
Copy link

@christopherpross christopherpross commented May 18, 2020

Hey,
my name is christopher proß. thank you for this grate project and for this tutorial. My question is the following:
I am writing at the moment an add-on for a screen-reader called nvda, a program which reads out screen elements too the blind on windows system. This program has the ability to be extended with add-ons in python. Which are executed at runtime. I would use this project for an add-on, but my problem is, to delever this requeriments to the end-users. exists there a way to precompile or prepack this all requeriments or pack it all to geter in an installer? Maybe someone can help me here.
All the best.

@masoudr
Copy link
Author

@masoudr masoudr commented May 18, 2020

@christopherpross You better create a new issue for your problem as this issue is related to installation on Windows.
If you want to deliver this to your end-user one way is to compile it as a stand-alone executable that accepts your desire parameters. You can follow this issue for compiling the script. Next, you can grab the executable and use it in your app without worrying about its requirements.

@christopherpross
Copy link

@christopherpross christopherpross commented May 18, 2020

@masoudr thank you for your quick answer. an executable file is not my first choice, because I write a python script and this is only an add-on for an application. So importing it or call it like a dll seems to be better. call it as executable file over subprocess seems to me inperformant and not clean. Anyway. I had opened a new ussue. #1147

@AkulPat
Copy link

@AkulPat AkulPat commented May 26, 2020

@masoudr I don't know if someones already asked, but this does not work with any other ides? I've been trying to install it and I use vscode so I don't know if that is an issue?

@masoudr
Copy link
Author

@masoudr masoudr commented May 26, 2020

@AkulPat The IDE doesn't relate to the installation of any Python packages unless you use a wrong environment within the IDE.
Remember that for this installation you need Visual Studio Command Prompt so if you want to install it inside your IDE, make sure that you select it instead of Windows CMD.
If you still have a problem post your error log for clarification.

@progmars
Copy link

@progmars progmars commented May 26, 2020

@AkulPat or you can use a pre-built whl for Windows, as I did (see my post above) and then you won't need any build tools at all.
Caveat - those prebuilt wheels I found are available for older Pythons only and they seem to be without CUDA support, so it won't use GPU. For some tasks it's ok, it worked just fine for me for face feature extraction in real-time.

@raburgos
Copy link

@raburgos raburgos commented May 29, 2020

Hi, here is something that works for me:

1.- conda create -n face_recognition python==3.6.6 anaconda

2.- conda activate face_recognition

3.- pip install cmake

4.- pip install dlib==19.8.1

5.- pip install face_recognition

6.- pip install opencv-contrib-python==4.1.0.25

7.- pip install twisted

@akeilox
Copy link

@akeilox akeilox commented May 30, 2020

@raburgos thanks for the 7 steps.

I have tried step 1 on windows 10 pro with anaconda3x64 but i get the following at the end of packages, not sure if this is a required part as I am attempting to continue with the next steps;

ERROR conda.core.link:_execute(507): An error occurred while installing package 'conda-forge::alabaster-0.7.12-py_0'.
FileNotFoundError(2, 'The system cannot find the file specified', None, 2, None)
Attempting to roll back.

@raburgos
Copy link

@raburgos raburgos commented May 30, 2020

@raburgos thanks for the 7 steps.

I have tried step 1 on windows 10 pro with anaconda3x64 but i get the following at the end of packages, not sure if this is a required part as I am attempting to continue with the next steps;

ERROR conda.core.link:_execute(507): An error occurred while installing package 'conda-forge::alabaster-0.7.12-py_0'.
FileNotFoundError(2, 'The system cannot find the file specified', None, 2, None)
Attempting to roll back.

Hi!

It seems to be something with anaconda ... maybe you could try in command line: conda update ipykernel and then conda update --all

First step creates virtual environment in order to isolate the project (with Python versión 3.6)

@akeilox
Copy link

@akeilox akeilox commented May 30, 2020

thanks for the direction.

guess im missing something here?

(base) C:\Users\acm>conda update ipykernel and then conda update --all
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  • and
  • then
  • update
@raburgos
Copy link

@raburgos raburgos commented May 30, 2020

thanks for the direction.

guess im missing something here?

(base) C:\Users\acm>conda update ipykernel and then conda update --all
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  • and
  • then
  • update

Should be this(press enter):
Command line: conda update ipykernel
——————-
And then:
——————-
Command line: conda update --all

@akeilox
Copy link

@akeilox akeilox commented May 30, 2020

oh wee thats embarrassing, yet to fully wake up.. update in progress, will try the steps again after all updated

@raburgos
Copy link

@raburgos raburgos commented May 30, 2020

oh wee thats embarrassing, yet to fully wake up.. update in progress, will try the steps again after all updated

don´t worry about that! let me know if it works for you!

@akeilox
Copy link

@akeilox akeilox commented May 30, 2020

@raburgos this works beautifully! thanks a million!
was on conda 4.8.3, open Anaconda Prompt

conda update ipykernel
conda update --all

repeat the above update till no error (took few runs for me), then run:

conda create -n face_recognition python==3.6.6 anaconda
conda activate face_recognition
pip install cmake
pip install dlib==19.8.1
pip install face_recognition
pip install opencv-contrib-python==4.1.0.25
pip install twisted

then clone the repo with git clone https://github.com/ageitgey/face_recognition.git
cd examples
face_detection ./

(that should output detected faces of pictures in that folder.

@raburgos
Copy link

@raburgos raburgos commented May 30, 2020

@raburgos this works beautifully! thanks a million!
was on conda 4.8.3, open Anaconda Prompt

conda update ipykernel
conda update --all

repeat the above update till no error (took few runs for me), then run:

conda create -n face_recognition python==3.6.6 anaconda
conda activate face_recognition
pip install cmake
pip install dlib==19.8.1
pip install face_recognition
pip install opencv-contrib-python==4.1.0.25
pip install twisted

then clone the repo with git clone https://github.com/ageitgey/face_recognition.git
cd examples
face_detection ./

(that should output detected faces of pictures in that folder.

That’s great!

@Yipeng-Wang-Peter
Copy link

@Yipeng-Wang-Peter Yipeng-Wang-Peter commented Jul 17, 2020

Thank you for your instruction! I have installed it successfully.
Does anyone know how to execute the facial recognition's command line on window 10?

Thank you.

@raburgos
Copy link

@raburgos raburgos commented Jul 18, 2020

Thank you for your instruction! I have installed it successfully.
Does anyone know how to execute the facial recognition's command line on window 10?

Thank you.

Hi @Yipeng-Wang-Peter !

If you want to use your webcam you can try in command line (e.g: anaconda prompt, considering current path in your local file face_recognition):
.- cd examples
.- python facerec_from_webcam_faster.py

I hope this helps!

@Yipeng-Wang-Peter
Copy link

@Yipeng-Wang-Peter Yipeng-Wang-Peter commented Jul 18, 2020

Thank you for your instruction! I have installed it successfully.
Does anyone know how to execute the facial recognition's command line on window 10?
Thank you.

Hi @Yipeng-Wang-Peter !

If you want to use your webcam you can try in command line (e.g: anaconda prompt, considering current path in your local file face_recognition):
.- cd examples
.- python facerec_from_webcam_faster.py

I hope this helps!

OK. Thank you!

@AlpeshValvi123
Copy link

@AlpeshValvi123 AlpeshValvi123 commented Jul 29, 2020

Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1:
command: 'd:\pythonpractice\pictures\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\avalvi\AppData\Local\Temp\pip-install-2u4dltn8\dlib\setup.py'"'"'; file='"'"'C:\Users\avalvi\AppData\Local\Temp\pip-install-2u4dltn8\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\avalvi\AppData\Local\Temp\pip-record-zs9fffxc\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\pythonpractice\pictures\include\site\python3.8\dlib'
cwd: C:\Users\avalvi\AppData\Local\Temp\pip-install-2u4dltn8\dlib
Complete output (74 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.4 (tags/v3.8.4:dfa645a, Jul 13 2020, 16:30:28) [MSC v.1926 32 bit (Intel)]
Invoking CMake setup: 'cmake C:\Users\avalvi\AppData\Local\Temp\pip-install-2u4dltn8\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\avalvi\AppData\Local\Temp\pip-install-2u4dltn8\dlib\build\lib.win32-3.8 -DPYTHON_EXECUTABLE=d:\pythonpractice\pictures\scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\avalvi\AppData\Local\Temp\pip-install-2u4dltn8\dlib\build\lib.win32-3.8'
-- Building for: Visual Studio 10 2010
CMake Error at CMakeLists.txt:3 (project):

@progmars
Copy link

@progmars progmars commented Jul 29, 2020

(project):

... and it stops at the most interesting part where the root cause of the error is located.

Python 3.8 - not sure if everything will work smoothly with the latest & greatest version. Why not try something that works, following the instructions given in the older comments here?

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

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.