You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code中无法安装dlib求助:已尝试全网方案仍失败附报错日志

Fixing dlib Installation Failures on Windows with Python 3.8

Hey there, I’ve looked through your error logs and can pinpoint exactly what’s blocking your dlib install when running pip install dlib --user:

The root issues are twofold:

  1. CMake is trying to use the NMake Makefiles generator, which doesn’t support specifying the x64 platform.
  2. Your system lacks a properly configured C/C++ compiler, causing the CMAKE_C_COMPILER not set and CMAKE_CXX_COMPILER not set errors.

Here are straightforward, actionable solutions to get dlib up and running:

Option 1: Install Precompiled dlib (No Compilation Required)

Skip the build process entirely with a pre-built package:

  • Run this command instead:
    pip install dlib-bin --user
    
  • If that doesn’t work, grab the exact Python 3.8 (64-bit) dlib wheel from the unofficial Windows binaries collection, then install it directly:
    pip install path/to/dlib-19.19.0-cp38-cp38-win_amd64.whl --user
    

Option 2: Set Up a Proper Compilation Environment

If you need to build dlib from source (for custom tweaks), follow these steps:

  1. Install Visual Studio Build Tools

    • Download and launch the Visual Studio Build Tools installer
    • Select the Desktop development with C++ workload, and ensure these components are checked:
      • MSVC v142 (or newer) Build Tools
      • Windows 10/11 SDK
      • CMake tools for Windows
    • Finish installation and restart your system.
  2. Use the Correct Command Prompt

    • Open the x64 Native Tools Command Prompt for Visual Studio 20xx (matches the version you installed)
    • Navigate to your project folder in this prompt, then run:
      pip install dlib --user
      

    This prompt automatically configures the 64-bit compilation environment, so CMake will use the right generator and detect your compilers correctly.


Your Original Error Log for Reference

Collecting dlib
Using cached https://files.pythonhosted.org/packages/63/92/05c3b98636661cb80d190a5a777dd94effcc14c0f6893222e5ca81e74fbc/dlib-19.19.0.tar.gz
Installing collected packages: dlib
Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1:
command: 'c:\program files\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\abhigna reddy\\AppData\\Local\\Temp\\pip-install-b3pu5qni\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\abhigna reddy\\AppData\\Local\\Temp\\pip-install-b3pu5qni\\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\abhigna reddy\AppData\Local\Temp\pip-record-dpfk1_ko\install-record.txt' --single-version-externally-managed --compile --user --prefix=
cwd: C:\Users\abhigna reddy\AppData\Local\Temp\pip-install-b3pu5qni\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.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\abhigna reddy\AppData\Local\Temp\pip-install-b3pu5qni\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\abhigna reddy\AppData\Local\Temp\pip-install-b3pu5qni\dlib\build\lib.win-amd64-3.8 -DPYTHON_EXECUTABLE=c:\program files\python38\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\abhigna reddy\AppData\Local\Temp\pip-install-b3pu5qni\dlib\build\lib.win-amd64-3.8 -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/abhigna reddy/AppData/Local/Temp/pip-install-b3pu5qni/dlib/build/temp.win-amd64-3.8/Release/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\abhigna reddy\AppData\Local\Temp\pip-install-b3pu5qni\dlib\setup.py", line 223, in <module>
    setup(
  File "c:\program files\python38\lib\site-packages\setuptools\__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "c:\program files\python38\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "c:\program files\python38\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "c:\program files\python38\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "c:\program files\python38\lib\site-packages\setuptools\command\install.py", line 61, in run
    return orig.install.run(self)
  File "c:\program files\python38\lib\distutils\command\install.py", line 545, in run
    self.run_command('build')
  File "c:\program files\python38\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\program files\python38\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "c:\program files\python38\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "c:\program files\python38\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\program files\python38\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\abhigna reddy\AppData\Local\Temp\pip-install-b3pu5qni\dlib\setup.py", line 135, in run
    self.build_extension(ext)
  File "C:\Users\abhigna reddy\AppData\Local\Temp\pip-install-b3pu5qni\dlib\setup.py", line 172, in build_extension
    subprocess.check_call(cmake_setup, cwd=build_folder)
  File "c:\program files\python38\lib\subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '["cmake", "C:\\Users\\abhigna reddy\\AppData\\Local\\Temp\\pip-install-b3pu5qni\\dlib\\tools\\python", "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\abhigna reddy\\AppData\\Local\\Temp\\pip-install-b3pu5qni\\dlib\\build\\lib.win-amd64-3.8", "-DPYTHON_EXECUTABLE=c:\\program files\\python38\\python.exe", "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\abhigna reddy\\AppData\\Local\\Temp\\pip-install-b3pu5qni\\dlib\\build\\lib.win-amd64-3.8", "-A", "x64"]' returned non-zero exit status 1.
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\program files\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\abhigna reddy\\AppData\\Local\\Temp\\pip-install-b3pu5qni\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\abhigna reddy\\AppData\\Local\\Temp\\pip-install-b3pu5qni\\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\abhigna reddy\AppData\Local\Temp\pip-record-dpfk1_ko\install-record.txt' --single-version-externally-managed --compile --user --prefix=
Check the logs for full command output.

内容的提问来源于stack exchange,提问作者abhigna mareddy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 23:32:28