命令行运行pip install dlib==19.24.0 --no-cache-dir --verbose报错: Using pip 25.1.1 from D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip (python 3.13) Collecting dlib==19.24.0 Downloading dlib-19.24.0.tar.gz (3.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 100.9 kB/s eta 0:00:00 Running command python setup.py egg_info C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:212: SyntaxWarning: invalid escape sequence '\(' major = re.findall("set\(CPACK_PACKAGE_VERSION_MAJOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:213: SyntaxWarning: invalid escape sequence '\(' minor = re.findall("set\(CPACK_PACKAGE_VERSION_MINOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:214: SyntaxWarning: invalid escape sequence '\(' patch = re.findall("set\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:194: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated. !! ******************************************************************************** Please remove any references to `setuptools.command.test` in all supported versions of the affected package. This deprecation is overdue, please update your project and remove deprecated calls to avoid build errors in the future. ******************************************************************************** !! from setuptools.command.test import test as TestCommand D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option: 'tests_require' warnings.warn(msg) running egg_info creating C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info writing C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\PKG-INFO writing dependency_links to C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\dependency_links.txt writing top-level names to C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\top_level.txt writing manifest file 'C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\SOURCES.txt' reading manifest file 'C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'tools\python\build*' no previously-included directories found matching 'dlib\cmake_utils\*\build*' no previously-included directories found matching 'dlib\test' warning: no previously-included files matching '*.pyc' found anywhere in distribution writing manifest file 'C:\Users\徐庆凯\AppData\Local\Temp\pip-pip-egg-info-x4hwlbut\dlib.egg-info\SOURCES.txt' Preparing metadata (setup.py) ... done Building wheels for collected packages: dlib DEPRECATION: Building 'dlib' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'dlib'. Discussion can be found at https://github.com/pypa/pip/issues/6334 Running command python setup.py bdist_wheel C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:212: SyntaxWarning: invalid escape sequence '\(' major = re.findall("set\(CPACK_PACKAGE_VERSION_MAJOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:213: SyntaxWarning: invalid escape sequence '\(' minor = re.findall("set\(CPACK_PACKAGE_VERSION_MINOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:214: SyntaxWarning: invalid escape sequence '\(' patch = re.findall("set\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:194: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated. !! ******************************************************************************** Please remove any references to `setuptools.command.test` in all supported versions of the affected package. This deprecation is overdue, please update your project and remove deprecated calls to avoid build errors in the future. ******************************************************************************** !! from setuptools.command.test import test as TestCommand D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option: 'tests_require' warnings.warn(msg) running bdist_wheel running build running build_py running build_ext C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. if LooseVersion(cmake_version) < '3.1.0': Building extension for Python 3.13.5 (tags/v3.13.5:6cb20a2, Jun 11 2025, 16:15:46) [MSC v.1943 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\build\lib.win-amd64-cpython-313 -DPYTHON_EXECUTABLE=D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\build\lib.win-amd64-cpython-313 -A x64' Traceback (most recent call last): File "<string>", line 2, in <module> exec(compile(''' ~~~~^^^^^^^^^^^^ # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<32 lines>... exec(compile(setup_py_code, filename, "exec")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ''' % ('C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\setup.py',), "<pip-setuptools-caller>", "exec")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<pip-setuptools-caller>", line 35, in <module> File "C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py", line 222, in <module> setup( ~~~~~^ name='dlib', ^^^^^^^^^^^^ ...<38 lines>... ], ^^ ) ^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\__init__.py", line 115, in setup return distutils.core.setup(**attrs) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\core.py", line 186, in setup return run_commands(dist) File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\core.py", line 202, in run_commands dist.run_commands() ~~~~~~~~~~~~~~~~~^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py", line 1002, in run_commands self.run_command(cmd) ~~~~~~~~~~~~~~~~^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\dist.py", line 1102, in run_command super().run_command(command) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py", line 1021, in run_command cmd_obj.run() ~~~~~~~~~~~^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\command\bdist_wheel.py", line 370, in run self.run_command("build") ~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\cmd.py", line 357, in run_command self.distribution.run_command(command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\dist.py", line 1102, in run_command super().run_command(command) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py", line 1021, in run_command cmd_obj.run() ~~~~~~~~~~~^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run self.run_command(cmd_name) ~~~~~~~~~~~~~~~~^^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\cmd.py", line 357, in run_command self.distribution.run_command(command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\dist.py", line 1102, in run_command super().run_command(command) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py", line 1021, in run_command cmd_obj.run() ~~~~~~~~~~~^^ File "C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py", line 134, in run self.build_extension(ext) ~~~~~~~~~~~~~~~~~~~~^^^^^ File "C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py", line 171, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\subprocess.py", line 419, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\build\\lib.win-amd64-cpython-313', '-DPYTHON_EXECUTABLE=D:\\Users\\徐庆凯\\AppData\\Local\\Programs\\Python\\Python313\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\build\\lib.win-amd64-cpython-313', '-A', 'x64']' returned non-zero exit status 3221226505. error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: 'D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\python.exe' -u -c ' exec(compile('"'"''"'"''"'"' # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py # # - It imports setuptools before invoking setup.py, to enable projects that directly # import from `distutils.core` to work with newer packaging standards. # - It provides a clear error message when setuptools is not installed. # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so # setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning: # manifest_maker: standard file '"'"'-c'"'"' not found". # - It generates a shim setup.py, for handling setup.cfg-only projects. import os, sys, tokenize, traceback try: import setuptools except ImportError: print( "ERROR: Can not execute `setup.py` since setuptools failed to import in " "the build environment with exception:", file=sys.stderr, ) traceback.print_exc() sys.exit(1) __file__ = %r sys.argv[0] = __file__ if os.path.exists(__file__): filename = __file__ with tokenize.open(__file__) as f: setup_py_code = f.read() else: filename = "<auto-generated setuptools caller>" setup_py_code = "from setuptools import setup; setup()" exec(compile(setup_py_code, filename, "exec")) '"'"''"'"''"'"' % ('"'"'C:\\Users\\徐庆凯\\AppData\\Local\\Temp\\pip-install-1bugzpia\\dlib_3252fe8772d348fc97cbac2fb469313f\\setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' bdist_wheel -d 'C:\Users\徐庆凯\AppData\Local\Temp\pip-wheel-m03b8zax' cwd: C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\\ Building wheel for dlib (setup.py) ... error ERROR: Failed building wheel for dlib Running setup.py clean for dlib Running command python setup.py clean C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:212: SyntaxWarning: invalid escape sequence '\(' major = re.findall("set\(CPACK_PACKAGE_VERSION_MAJOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:213: SyntaxWarning: invalid escape sequence '\(' minor = re.findall("set\(CPACK_PACKAGE_VERSION_MINOR.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:214: SyntaxWarning: invalid escape sequence '\(' patch = re.findall("set\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open(cmake_file).read())[0] C:\Users\徐庆凯\AppData\Local\Temp\pip-install-1bugzpia\dlib_3252fe8772d348fc97cbac2fb469313f\setup.py:194: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated. !! ******************************************************************************** Please remove any references to `setuptools.command.test` in all supported versions of the affected package. This deprecation is overdue, please update your project and remove deprecated calls to avoid build errors in the future. ******************************************************************************** !! from setuptools.command.test import test as TestCommand D:\Users\徐庆凯\AppData\Local\Programs\Python\Python313\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option: 'tests_require' warnings.warn(msg) running clean removing 'build\temp.win-amd64-cpython-313' (and everything under it) 'build\lib.win-amd64-cpython-313' does not exist -- can't clean it 'build\bdist.win-amd64' does not exist -- can't clean it 'build\scripts-3.13' does not exist -- can't clean it removing 'build' Failed to build dlib ERROR: Failed to build installable wheels for some pyproject.toml based projects (dlib)
时间: 2025-07-30 22:31:40 浏览: 13
<think>我们正在解决在Python3.13环境下使用pip安装dlib==19.24.0时出现的CMake配置错误和subprocess.CalledProcessError问题。根据引用[1]中的信息,我们可以尝试以下步骤:1.**确保系统有编译依赖**:dlib需要C++编译器和相关工具。在Linux上,安装build-essential和cmake。在macOS上,安装Xcode命令行工具。在Windows上,安装VisualStudio的C++构建工具。2.**设置环境变量(针对Linux/macOS)**:引用[1]提到,可以通过设置环境变量指定gcc和g++的路径。例如:```bashexportCC=/usr/bin/gccexportCXX=/usr/bin/g++```注意:路径可能因系统而异,请使用`whichgcc`和`whichg++`查看实际路径。3.**使用清华镜像源安装**:引用[1]建议使用清华镜像源安装face_recognition,这同样适用于dlib。我们可以先尝试安装dlib:```bashpipinstalldlib==19.24.0-ihttps://pypi.tuna.tsinghua.edu.cn/simple```4.**如果上述步骤失败,尝试从源码安装**:-下载dlib源码:https://github.com/davisking/dlib/releases-解压后进入目录,执行:```bashpythonsetup.pyinstall```5.**注意Python3.13的兼容性**:目前dlib可能尚未完全支持Python3.13。如果遇到兼容性问题,可以尝试:-使用较新的dlib版本(如果有)或较旧的Python版本(如3.10、3.11)。-在虚拟环境中安装,避免系统环境冲突。6.**错误日志分析**:如果仍然失败,请提供具体的错误日志,以便进一步分析。**步骤总结**:1.安装编译依赖。2.设置环境变量指定编译器(如果需要)。3.使用镜像源安装dlib。4.尝试源码安装。5.考虑Python版本兼容性。如果以上步骤不能解决,请提供具体的错误信息。</think>### 解决 Python 3.13 下安装 dlib==19.24.0 的 CMake 错误
安装 dlib 时出现 CMake 配置错误和 `subprocess.CalledProcessError` 通常是由于以下原因:
1. **编译器不兼容**:Python 3.13 可能需要更新的编译器
2. **CMake 版本过低**:dlib 需要 CMake ≥ 3.8.2
3. **依赖缺失**:缺少 C++ 构建工具链
4. **Python 版本兼容性**:dlib 19.24.0 可能未完全适配 Python 3.13
#### 解决方案步骤:
1. **升级构建工具**:
```bash
# Linux
sudo apt update && sudo apt install build-essential cmake
# macOS (需安装 Xcode 命令行工具)
xcode-select --install
```
2. **设置环境变量**(关键步骤):
```bash
# 指定正确的编译器路径(根据实际路径调整)
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
```
使用 `which gcc` 和 `which g++` 确认路径[^1]
3. **安装 CMake 最新版**:
```bash
pip install --upgrade cmake
```
4. **使用兼容性安装命令**:
```bash
pip install dlib==19.24.0 \
--no-cache-dir \
--force-reinstall \
--config-settings="--global-option=--no" \
--config-settings="--global-option=--clean" \
-i https://pypi.tuna.tsinghua.edu.cn/simple
```
5. **备选方案 - 从源码编译**:
```bash
git clone https://github.com/davisking/dlib.git
cd dlib
mkdir build && cd build
cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1
cmake --build . --config Release
cd .. && pip install .
```
#### 验证安装:
```python
import dlib
print(dlib.__version__) # 应输出 19.24.0
```
> **注意**:如果仍失败,建议:
> 1. 临时降级到 Python 3.11/3.12
> 2. 使用虚拟环境隔离安装:
> ```bash
> python -m venv dlib_env
> source dlib_env/bin/activate
> ```
阅读全文
相关推荐


















