Windows10下Python3.5.2安装face_recognition报错求助
Hey there, let's get this sorted out for you. Looking at your error logs, the core issue is with cmake not working properly when trying to compile the required dlib 19.16.0 version—face_recognition requires dlib >=19.7, which is why pip tried to uninstall your existing 19.1.0, but the compilation failed due to cmake issues.
问题根源
The key errors pointing us to the problem are:
ImportError: cannot import name 'cmake'from your Python'scmake.exescriptsubprocess.CalledProcessError: Command '['cmake', '--version']' returned non-zero exit status 1
This means the cmake you're using is likely the Python package version, not a proper system-level cmake installation—and that Python package is broken or incompatible with building dlib.
分步解决方案
Let's fix this step by step:
移除有问题的Python版cmake包
打开命令提示符,执行:pip uninstall cmake -y这会删掉导致导入错误的Python版cmake。
安装系统级的cmake
- 下载Windows版的官方cmake安装程序(注意匹配你的系统架构:32位或64位)
- 安装时务必勾选“将cmake添加到系统PATH”选项(可选为所有用户或当前用户)
- 打开新的命令提示符,验证安装成功:
你应该能看到有效的版本号(dlib编译要求cmake至少3.8,所以任何新版本都可以)。cmake --version
安装适配Python 3.5的预编译dlib wheel包(避免源码编译)
Windows下源码编译dlib容易出问题,直接用预编译的wheel更稳妥:- 找到对应Python 3.5和系统架构的dlib wheel文件(比如64位系统对应
dlib-19.16.0-cp35-cp35m-win_amd64.whl) - 用pip安装:
pip install path/to/your/dlib-wheel-file.whl
注意:把
path/to/your/dlib-wheel-file.whl替换成你保存wheel文件的实际路径- 找到对应Python 3.5和系统架构的dlib wheel文件(比如64位系统对应
最终安装face_recognition
确认dlib 19.16.0(或更高版本)安装成功后,执行:pip install face_recognition
额外注意事项
- 确保你用的是Python 3.5对应的pip——执行
pip --version,确认路径指向c:\python35\Scripts\pip.exe - 如果之前有过失败的安装尝试,先清理残留:
再重新执行上面的步骤。pip uninstall dlib face_recognition -y
内容的提问来源于stack exchange,提问作者Sruthipriyanga

