1. 安装和配置Visual Studio
- 1.1. 下载安装器:
- 1.2. 安装核心组件:
- 1.3. 设置环境变量
- 2. 安装cmake
- 2.1. 运行pip install cmake,进行安装
- 2.2. 配置环境变量(我不清楚这一步是否必需)
- 3. 安装face_recognition或者dlib
- 4. Q&A
- 问题1:pip install dlib时,报错:No CMAKE_C_COMPILER could be found
- 问题2:pip install dlib时,报错: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++.
- 问题3:pip install dlib时,报错:CMake must be installed to build dlib
- 5. 感谢
开始研究face_recognition,在安装过程中,遇到dlib模块无法安装的问题,网上查了很多帖子,现将最终解决方法记录下来
1. 安装和配置Visual Studio
1.1. 下载安装器:
访问:[https://visualstudio.microsoft.com/zh-hans/downloads/] 下载Visual Studio安装器
1.2. 安装核心组件:
如下图,在“单个组件”中,选择以下2个组件:
MSVC v143 - VS 2022 C++ x64/x86 生成工具(最新) – 可能版本号会更新
Windows 10 SDK (10.0.20348.0) – 这个版本号直接选择最新的
1.3. 设置环境变量
先去VS的安装目录下,查询cl.exe,会查出4个文件,应该是对应于4种不同位数的操作系统,我们选择文件路径结尾是Hostx86\x86的即可。
比如,我的路径为:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86
将这个路径,配置到Path环境变量下:
此时,在DOS窗口,运行cl命令,能够返回如下结果:
2. 安装cmake
2.1. 运行pip install cmake,进行安装
2.2. 配置环境变量(我不清楚这一步是否必需)
先到如下路径中,找到cmake.exe
将这个路径,配置到Path环境变量下:
此时,在DOS窗口,运行cmake命令,能够返回如下结果:
3. 安装face_recognition或者dlib
最后直接pip install face_recognition,系统会自动先安装dlib
4. Q&A
问题1:pip install dlib时,报错:No CMAKE_C_COMPILER could be found
解决:在安装VS时,需要选择Windows 10 SDK (10.0.20348.0)
问题2:pip install dlib时,报错: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++.
解决:按照文字的第一步,安装VS的2个核心组件,并配置cl.exe的环境变量
问题3:pip install dlib时,报错:CMake must be installed to build dlib
解决:先pip install cmake,再pip install dlib