Python 3.9环境下安装DeepFace失败,求解决方法
安装DeepFace库失败的解决方案
问题描述
在Windows设备上使用Python 3.9执行pip install deepface时安装失败,核心原因是安装依赖包pandas 2.2.0时,Meson构建系统无法解析vswhere.exe的输出,具体报错信息如下:
C:\Windows\System32>pip install deepface Collecting deepface Using cached deepface-0.0.83-py3-none-any.whl.metadata (24 kB) Collecting numpy>=1.14.0 (from deepface) Using cached numpy-1.26.3-cp39-cp39-win32.whl.metadata (61 kB) Collecting pandas>=0.23.4 (from deepface) Using cached pandas-2.2.0.tar.gz (4.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [12 lines of output] + meson setup C:\Users\serra\AppData\Local\Temp\pip-install-dzbpz4hn\pandas_44529345be024d60848bd5ace395cfd7 C:\Users\serra\AppData\Local\Temp\pip-install-dzbpz4hn\pandas_44529345be024d60848bd5ace395cfd7\.mesonpy-58bg2nid\build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --vsenv --native-file=C:\Users\serra\AppData\Local\Temp\pip-install-dzbpz4hn\pandas_44529345be024d60848bd5ace395cfd7\.mesonpy-58bg2nid\build\meson-python-native-file.ini The Meson build system Version: 1.2.1 Source dir: C:\Users\serra\AppData\Local\Temp\pip-install-dzbpz4hn\pandas_44529345be024d60848bd5ace395cfd7 Build dir: C:\Users\serra\AppData\Local\Temp\pip-install-dzbpz4hn\pandas_44529345be024d60848bd5ace395cfd7\.mesonpy-58bg2nid\build Build type: native build Project name: pandas Project version: 2.2.0 ..\..\meson.build:2:0: ERROR: Could not parse vswhere.exe output A full log can be found at C:\Users\serra\AppData\Local\Temp\pip-install-dzbpz4hn\pandas_44529345be024d60848bd5ace395cfd7\.mesonpy-58bg2nid\build\meson-logs\meson-log.txt [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
可行解决方案
方案1:安装兼容Python 3.9的pandas版本后再装DeepFace
pandas 2.2.0已不再支持Python 3.9,pip默认拉取该版本时会触发源码编译,进而引发vswhere解析错误。先手动安装兼容的旧版本pandas,再安装DeepFace:
- 执行命令:
pip install pandas==2.1.4 - 再执行:
pip install deepface
方案2:使用虚拟环境隔离依赖
避免全局环境的依赖冲突,创建Python 3.9专属的虚拟环境后再安装:
- 创建虚拟环境:
python -m venv deepface_env - 激活虚拟环境:
deepface_env\Scripts\activate - 安装兼容版pandas:
pip install pandas==2.1.4 - 安装DeepFace:
pip install deepface
方案3:安装Visual Studio Build Tools解决编译依赖
如果必须使用最新版pandas,需要补充编译所需的系统依赖:
- 下载并安装Visual Studio Build Tools,勾选"Desktop development with C++"组件,确保包含MSVC编译器、Windows SDK等核心编译工具
- 安装完成后重启命令提示符,重新执行
pip install deepface
内容的提问来源于stack exchange,提问作者Kishiroh
相关产品推荐
相关产品推荐

