0

I'm having difficulties installing dlib 19.24.0 for Stable Diffusion. I've got Python 3.10.11 installed. When launching the Automatic 1111 Web UI, it fails to install dlib. So I tried installing directly via the console like this:

C:\Windows\System32>pip install dlib==19.24.0

After doing so, the console returns a long error that ends with this message:

ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects

Here is the full output after attempting the install command.

  Collecting dlib==19.24.0
  Using cached dlib-19.24.0.tar.gz (3.2 MB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [68 lines of output]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      C:\Users\kenpa\AppData\Local\Temp\pip-install-us0rb766\dlib_71fc7c85fef145f580765efe56a6152b\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        if LooseVersion(cmake_version) < '3.1.0':
      Building extension for Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
      Invoking CMake setup: 'cmake C:\Users\kenpa\AppData\Local\Temp\pip-install-us0rb766\dlib_71fc7c85fef145f580765efe56a6152b\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\kenpa\AppData\Local\Temp\pip-install-us0rb766\dlib_71fc7c85fef145f580765efe56a6152b\build\lib.win-amd64-cpython-310 -DPYTHON_EXECUTABLE=C:\Users\kenpa\AppData\Local\Programs\Python\Python310\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\kenpa\AppData\Local\Temp\pip-install-us0rb766\dlib_71fc7c85fef145f580765efe56a6152b\build\lib.win-amd64-cpython-310 -A x64'
      -- Building for: NMake Makefiles
      CMake Error at CMakeLists.txt:5 (message):



        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


        You must use Visual Studio to build a python extension on windows.  If you
        are getting this error it means you have not installed Visual C++.  Note
        that there are many flavors of Visual Studio, like Visual Studio for C#
        development.  You need to install Visual Studio for C++.


        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




  -- Configuring incomplete, errors occurred!
  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "C:\Users\kenpa\AppData\Local\Temp\pip-install-us0rb766\dlib_71fc7c85fef145f580765efe56a6152b\setup.py", line 222, in <module>
      setup(
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\__init__.py", line 107, in setup
      return distutils.core.setup(**attrs)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
      return run_commands(dist)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
      dist.run_commands()
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
      self.run_command(cmd)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\dist.py", line 1234, in run_command
      super().run_command(command)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\wheel\bdist_wheel.py", line 325, in run
      self.run_command("build")
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\dist.py", line 1234, in run_command
      super().run_command(command)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run
      self.run_command(cmd_name)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\dist.py", line 1234, in run_command
      super().run_command(command)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "C:\Users\kenpa\AppData\Local\Temp\pip-install-us0rb766\dlib_71fc7c85fef145f580765efe56a6152b\setup.py", line 134, in run
      self.build_extension(ext)
    File "C:\Users\kenpa\AppData\Local\Temp\pip-install-us0rb766\dlib_71fc7c85fef145f580765efe56a6152b\setup.py", line 171, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "C:\Users\kenpa\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\kenpa\\AppData\\Local\\Temp\\pip-install-us0rb766\\dlib_71fc7c85fef145f580765efe56a6152b\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\kenpa\\AppData\\Local\\Temp\\pip-install-us0rb766\\dlib_71fc7c85fef145f580765efe56a6152b\\build\\lib.win-amd64-cpython-310', '-DPYTHON_EXECUTABLE=C:\\Users\\kenpa\\AppData\\Local\\Programs\\Python\\Python310\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\kenpa\\AppData\\Local\\Temp\\pip-install-us0rb766\\dlib_71fc7c85fef145f580765efe56a6152b\\build\\lib.win-amd64-cpython-310', '-A', 'x64']' returned non-zero exit status 1.
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for dlib
  Running setup.py clean for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects

I do have Visual Studio Code installed. And CMake is installed and is in my user and system environment variables, like so:

cmake path in system settings

How can I successfully install dlib 19.24.0? Thanks.

Ken Palmer
  • 2,355
  • 5
  • 37
  • 57
  • "I do have Visual Studio Code installed." - **Visual Studio Code**, which you have, and **Visual Studio**, which is required, are absolutely **unrelated** things. – Tsyvarev Jul 27 '23 at 07:16
  • Right. So is this part of the message relevant? "You must use Visual Studio to build a python extension on windows." And if so is there a downloadable Python extension that someone with VS has posted? – Ken Palmer Jul 27 '23 at 15:36

0 Answers0