How to solve issue related to installation of dlib on Windows 10?
Asked Answered
N

2

1

I am trying to install dlib for face-recognition for python 3.7 on windows 10, I explored few ways but I am getting errors.I tried below steps-

  1. Installed cmake using 'pip install cmake'. This worked.
  2. Downloaed the Dlib source(.tar.gz) from the Python Package Index : https://pypi.org/project/dlib/#files extract it and enter into the folder.
  3. Ran the installation: python setup.py install

I am getting below error.

*

*C:\Program Files\dlib-19.18.0>python setup.py install
running install
running bdist_egg
running egg_info
writing dlib.egg-info\PKG-INFO
writing dependency_links to dlib.egg-info\dependency_links.txt
writing top-level names to dlib.egg-info\top_level.txt
package init file 'dlib\__init__.py' not found (or not a regular file)
reading manifest file 'dlib.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tools\python\build*'
no previously-included directories found matching 'dlib\test'
writing manifest file 'dlib.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
Building extension for Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Program Files\dlib-19.18.0\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Program Files\dlib-19.18.0\build\lib.win-amd64-3.7 -DPYTHON_EXECUTABLE=C:\Users\Sriparna\Anaconda3\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Program Files\dlib-19.18.0\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:/Program Files/dlib-19.18.0/build/temp.win-amd64-3.7/Release/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
  File "setup.py", line 261, in <module>
    'Topic :: Software Development',
  File "C:\Users\Sriparna\Anaconda3\lib\site-packages\setuptools\__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\Sriparna\Anaconda3\lib\site-packages\setuptools\command\install.py", line 67, in run
    self.do_egg_install()
  File "C:\Users\Sriparna\Anaconda3\lib\site-packages\setuptools\command\install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\Sriparna\Anaconda3\lib\site-packages\setuptools\command\bdist_egg.py", line 172, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "C:\Users\Sriparna\Anaconda3\lib\site-packages\setuptools\command\bdist_egg.py", line 158, in call_command
    self.run_command(cmdname)
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\Sriparna\Anaconda3\lib\site-packages\setuptools\command\install_lib.py", line 11, in run
    self.build()
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\command\install_lib.py", line 107, in build
    self.run_command('build_ext')
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\Sriparna\Anaconda3\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 135, in run
    self.build_extension(ext)
  File "setup.py", line 172, in build_extension
    subprocess.check_call(cmake_setup, cwd=build_folder)
  File "C:\Users\Sriparna\Anaconda3\lib\subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Program Files\\dlib-19.18.0\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Program Files\\dlib-19.18.0\\build\\lib.win-amd64-3.7', '-DPYTHON_EXECUTABLE=C:\\Users\\Sriparna\\Anaconda3\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Program Files\\dlib-19.18.0\\build\\lib.win-amd64-3.7', '-A', 'x64']' returned non-zero exit status 1.*

*

Can you please advise how to solve this issue?

Nila answered 9/11, 2019 at 8:8 Comment(0)
A
1

In my system i'd done using Anaconda. The Dlib library supports python 3.6 to 3.7.0 in conda environments.

follow the instruction to install face recognition model,

  1. install Anaconda from https://www.anaconda.com/distribution/#download-section

  2. in conda prompt, create an environment using this command

    conda create --name env_name python=3.7.0

  3. then activate the env

    conda activate env_name

  4. install dlib

conda install -c conda-forge dlib=19.17

  1. now install face_recogintion models using pip

pip install face_recogntion

Adolf answered 14/11, 2019 at 12:55 Comment(1)
Hi, thanks. I did installation of Visual studio and then ran dlib installation from VS command prompt.It worked.Nila
Q
0

Installing face_recognition on Windows 10

Requirements:

  1. Microsoft Visual Studio 2015 (or newer) with C/C++ Compiler installed.

  2. Microsoft Visual C++ (MSVC) 14.0 installed (need to install the visual c++ build tools)

  3. CMake for windows and add it to your system environment variables

  4. Boost installed and added to system environment variables

  5. Python 3 with the same system type as your OS (ie. 64-bit, 32-bit)

Installing MSVC 14.0 and Cmake for windows

  1. Download Microsoft C++ build tools from https://visualstudio.microsoft.com/visual-cpp-build-tools/ and install
  2. Once the installation finished, click on modify in the Visual Studio Build Tools 2019 (2) section
  3. Go to the Individual components tab, under the Compilers, build tools, and runtimes, tick on C++ CMake tools for Windows and MSVC v140
  • VS 2015 C++ build tools (v14.00) and click modify. The Visual Studio Installer will begin to download and install MSVC 14.0 and Cmake for you

Adding MSVC 14.0 and Cmake to System Variables

  1. On the search tab, type This PC and right-click, choose properties
  2. Go to the Advanced system settings, under Advanced tab click on Environment Variables
  3. Under System variables, click New… and fill the following: Name: VS140COMNTOOLS Value: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
  4. Click OK
  5. Under User variables, click on variable named Path and click Edit…
  6. Click New and fill “C:\Program Files\CMake\bin”
  7. Click OK, click OK again

Installing Boost and face_recognition

  1. Download Boost library source code or binary release for your current MSVC from https://sourceforge.net/projects/boost/files/
  2. Extract the Boost source files into C:\local\boost_1_XX_X (X means the current version of Boost you have). You may need to create local directory
  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
  4. If you successfully compile Boost, it should create compiled files in stage directory
  5. Go to Command prompt and type $ pip install face_recognition
Quintus answered 6/7, 2020 at 9:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.