Error with Dlib installation for python on windows 10
Asked Answered
P

3

6

I'm trying to install dlib. I followed every single tip on the internet but its just not working. I'm using/tried

I have conda and pip installed, tried both with

  • pip install dlib
  • pip install dlib --verbose
  • pip install "some urls"
  • conda install -c conda-forge dlib
  • conda install -c conda-forge/label/cf201901 dlib

The error I'm getting is:

 Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 222, in <module>
        setup(
      File "c:\users\sophi\anaconda3\lib\site-packages\setuptools\__init__.py", line 159, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\sophi\anaconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\sophi\anaconda3\lib\site-packages\setuptools\command\install.py", line 68, in run
        return orig.install.run(self)
      File "c:\users\sophi\anaconda3\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "c:\users\sophi\anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\sophi\anaconda3\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\users\sophi\anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 134, in run
        self.build_extension(ext)
      File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 174, in build_extension
        subprocess.check_call(cmake_build, cwd=build_folder)
      File "c:\users\sophi\anaconda3\lib\subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1.
    Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1: 'c:\users\sophi\anaconda3\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\sophi\\AppData\\Local\\Temp\\pip-install-3w7lgrlb\\dlib_ffabe5e6a08e472b835f598e7803e3d4\\setup.py'"'"'; __file__='"'"'C:\\Users\\sophi\\AppData\\Local\\Temp\\pip-install-3w7lgrlb\\dlib_ffabe5e6a08e472b835f598e7803e3d4\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\sophi\AppData\Local\Temp\pip-record-kvd3vwdq\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\sophi\anaconda3\Include\dlib' Check the logs for full command output.

For me, it seems like the problem is somethin with the cmake command, but I have no idea what the exact problem is. I used pip install cmake and installed cmake from source, none of both worked. Has anyone an idea how to solve this?

Photocopier answered 3/11, 2021 at 17:58 Comment(2)
There's little info about the output of cmake --build . --config Release -- /m. Maybe this info is available via the full logs mentioned in the output you've posted. Alternatively it may provide you with info about how cmake is used, perhaps even a configured cmake project on the file system you could use to execute the cmake command to get more details about the issue.Etheline
I tried 'pip install --verbose dlib' but the output was pretty much the same. However, right now I managed to get dlib installed as I'm gonna mention in the answer below. Nevertheless, thank you for your advice (:Photocopier
U
3

This may be late response but I was facing the exact same issue when trying to install dlib on visual studio code. This was my error I was receiving when trying to run the command "pip install dlib"

Collecting dlib
Using cached dlib-19.23.1.tar.gz (7.4 MB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
  Running setup.py install for dlib ... error
  error: subprocess-exited-with-error

  × Running setup.py install for dlib did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      running install
      running build
      running build_py
      package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
      running build_ext

      ERROR: CMake must be installed to build dlib

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> dlib

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

So my next approach was to install cmake which where the installation worked however I receive a warning that the file path to the exe was not added to my path. This resulted when running "cmake --version" to outputted in terminal

'cmake' is not recognized as an internal or external command,
operable program or batch file.

I would suspected to not run correctly, and to fix this I simply copy the path that it had printed out to my terminal after install cmake and went to Advance System Settings -> Advanced Tab -> Environment Variables -> User Variables for 'your desktop name' open up "Path" -> click on new -> paste path

After following those steps running the command "cmake --version" correctly printed out the version install, meaning it is accessing the correct path. After that "pip install dlib" worked perfectly as proof below

Collecting dlib
  Using cached dlib-19.23.1.tar.gz (7.4 MB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
  Running setup.py install for dlib ... done
Successfully installed dlib-19.23.1

I hope this may help as it is one approach that worked for me in installing dlib. As you mention your cmake is on path I would check by running the command to see if the version is correctly printing out.

Urdu answered 4/5, 2022 at 4:46 Comment(0)
P
0

Althoug trying to test every combination of the commands mentioned in my question, there apparently was one combination I didn't try: Conda environment with python 3.6.4 and then

  • conda install -c conda-forge dlib

Not able to install dlib on Windows 10 and Python 3.7 As Berkay is mentioning, anaconda apparently requires python <=3.6.x, which solved it for me. ! pip install dlib would not work in this environment (probably because of another version problem with this environment) !

Photocopier answered 4/11, 2021 at 7:38 Comment(0)
C
0

One of the solution that i found is to first check the version of python on your pycharm environment terminal using command python --version

after that download the dlib version compatible with your python version from the following link Github Dlib_Windows_Python3.x

after downloading this file move the file to this location in your device

C:\Users\USER\

then form cmd promt execute the relevent command Python 3.7

python -m pip install dlib-19.22.99-cp37-cp37m-win_amd64.whl 

Python 3.8

python -m pip install dlib-19.22.99-cp38-cp38-win_amd64.whl

Python 3.9

python -m pip install dlib-19.22.99-cp39-cp39-win_amd64.whl

Python 3.10

python -m pip install dlib-19.22.99-cp310-cp310-win_amd64.whl

Python 3.11

python -m pip install dlib-19.24.1-cp311-cp311-win_amd64.whl

Cheers!

Carlcarla answered 3/5 at 11:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.