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

无法安装dlib:VSCode中执行pip install dlib报错求助

我尝试在VSCode中通过pip install dlib命令安装dlib库,但出现了如下错误:

Command "c:\users\admin\documents\python\pyai3.6\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\Admin\AppData\Local\Temp\pip-install-j42ksv_7\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\Admin\AppData\Local\Temp\pip-record-y1xi59yt\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\admin\documents\python\pyai3.6\include\site\python3.6\dlib" failed with error code 1 in C:\Users\Admin\AppData\Local\Temp\pip-install-j42ksv_7\dlib\
解决pip安装dlib报错(错误代码1)的方法

常见解决步骤

  • 安装编译依赖(Windows环境)

    1. 安装Visual Studio,勾选「使用C++的桌面开发」工作负载,确保包含MSVC编译器、Windows SDK组件。
    2. 安装CMake,并将其路径添加到系统环境变量PATH中,重启终端后执行cmake --version确认生效。
  • 使用预编译wheel包安装
    直接下载对应Python版本和系统架构的dlib wheel文件(比如Python3.6 64位对应dlib-19.xx-cp36-cp36m-win_amd64.whl),然后执行:

    pip install 下载的wheel文件名.whl
    

    注意要匹配自己的Python版本(cp36对应3.6,cp37对应3.7等)和系统位数(win_amd64是64位)。

  • 升级pip和setuptools
    执行以下命令更新工具,避免版本兼容问题:

    pip install --upgrade pip setuptools
    
  • 确认Python版本兼容性
    确保使用的是官方发布的Python3.6版本,非修改版或精简版,避免缺失必要组件导致编译失败。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 05:15:31