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

安装face_recognition与dlib遇错误:已装C++ CMake工具仍报错

解决dlib安装时的编译错误

问题重现

执行安装命令时出现以下错误:

cd C:\Users\Dnyaneshwar\AppData\Local\Programs\Python\Python311\Lib\site-packages
PS C:\Users\Dnyaneshwar\AppData\Local\Programs\Python\Python311\Lib\site-packages> python setup.py install

  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++.

  subprocess.check_call(cmake_setup, cwd=build_folder)
  File "C:\Users\Dnyaneshwar\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '[cmake, C:\\Users\\Dnyaneshwar\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Dnyaneshwar\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\build\\lib.win-amd64-cpython-311', '-DPYTHON_EXECUTABLE=C:\\Users\\Dnyaneshwar\\AppData\\Local\\Programs\\Python\\Python311\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Dnyaneshwar\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\build\\lib.win-amd64-cpython-311', '-A', 'x64']' returned non-zero exit status 1.

已安装Windows版C++ CMake工具,但问题依旧。

解决方案

  • 确认Visual Studio完整组件安装:打开Visual Studio Installer,勾选**Desktop development with C++**工作负载,确保包含MSVC v14x编译器、Windows 10/11 SDK、C++ CMake工具等核心组件,不要仅单独安装CMake工具。同时保证Python版本(3.11)与Visual Studio架构(x64)匹配。
  • 使用Visual Studio命令提示符执行安装:找到对应版本的x64 Native Tools Command Prompt for VS,以管理员身份启动,切换到dlib目录后重新执行python setup.py install。
  • 安装预编译包:跳过编译步骤,直接安装预编译的wheel包,执行pip install dlib-bin。
  • 检查CMake环境变量:确认CMake的安装路径已添加到系统PATH中,重启命令行工具后再尝试安装。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 19:55:34