权所有(C) Microsoft Corporation。保留所有权利。 安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows (.venv1) PS D:\OCR\AW> pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting altgraph==0.17.2 (from -r requirements.txt (line 1)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/84/3f/1a5c9bef54cac9bf41edd6f4aaf61cd52ed578e10ccc607e0278012cb4a5/altgraph-0.17.2-py2.py3-none-any.whl (21 kB) Collecting cycler==0.11.0 (from -r requirements.txt (line 2)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/5c/f9/695d6bedebd747e5eb0fe8fad57b72fdf25411273a39791cde838d5a8f51/cycler-0.11.0-py3-none-any.whl (6.4 kB) Collecting dlib==19.23.0 (from -r requirements.txt (line 3)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/25/0f/05e70b2ebf6a539c4c397c7c3dd19b69e0b3d650443e12a8af4866f65b03/dlib-19.23.0.tar.gz (3.2 MB) Preparing metadata (setup.py) ... done Collecting fonttools==4.33.3 (from -r requirements.txt (line 4)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2f/85/2f6e42fb4b537b9998835410578fb1973175b81691e9a82ab6668cf64b0b/fonttools-4.33.3-py3-none-any.whl (930 kB) Collecting future==0.18.2 (from -r requirements.txt (line 5)) Using cached future-0.18.2-py3-none-any.whl Collecting importlib-metadata==4.11.4 (from -r requirements.txt (line 6)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ab/b5/1bd220dd470b0b912fc31499e0d9c652007a60caf137995867ccc4b98cb6/importlib_metadata-4.11.4-py3-none-any.whl (18 kB) Collecting kiwisolver==1.4.2 (from -r requirements.txt (line 7)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/49/75/3a5f894ff63a2f13bd68d7962d01b9393bba139335cf9f47b2eb8739e63b/kiwisolver-1.4.2-cp39-cp39-win_amd64.whl (55 kB) Collecting matplotlib==3.5.2 (from -r requirements.txt (line 8)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/43/64/1d949d0fab5b83071290a46c93de28cbd8ff15a75b533d6c134012c61e4d/matplotlib-3.5.2-cp39-cp39-win_amd64.whl (7.2 MB) Collecting numpy==1.21.6 (from -r requirements.txt (line 9)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4d/04/bcd62448f2e772bc90a73ba21bacaa19817ae9905ae639969462862bd071/numpy-1.21.6-cp39-cp39-win_amd64.whl (14.0 MB) Collecting opencv-python==4.5.2.54 (from -r requirements.txt (line 10)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/7c/5d/5581984f71c3378f913057beb4a0c53a22d71dd1b6d49457314ecd26c5af/opencv_python-4.5.2.54-cp39-cp39-win_amd64.whl (34.7 MB) Collecting packaging==21.3 (from -r requirements.txt (line 11)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl (40 kB) Collecting pefile==2022.5.30 (from -r requirements.txt (line 12)) Using cached pefile-2022.5.30-py3-none-any.whl Collecting Pillow==9.1.1 (from -r requirements.txt (line 13)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/cc/d9/5d0c2a0146fe68781a1920fa2a68d81bc55de38bed50beb8bf2493e0c7c1/Pillow-9.1.1-cp39-cp39-win_amd64.whl (3.3 MB) Collecting pyinstaller==5.1 (from -r requirements.txt (line 14)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/39/0c/fcedab1fc19e4a7b275c5298bb9c69e411d5092ceaf5a167b611de4c023d/pyinstaller-5.1-py3-none-win_amd64.whl (1.2 MB) Collecting pyinstaller-hooks-contrib==2022.7 (from -r requirements.txt (line 15)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/de/97/9901350320f0454a04a937666235f532353c55507679cca9712464760431/pyinstaller_hooks_contrib-2022.7-py2.py3-none-any.whl (234 kB) Collecting pyparsing==3.0.9 (from -r requirements.txt (line 16)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/6c/10/a7d0fa5baea8fe7b50f448ab742f26f52b80bfca85ac2be9d35cdd9a3246/pyparsing-3.0.9-py3-none-any.whl (98 kB) Collecting PyQt5==5.15.6 (from -r requirements.txt (line 17)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/be/f2/8e7b751d102ce3500cbeff97cb514eaf5c06d5e423676c37e9de28d0c06b/PyQt5-5.15.6-cp36-abi3-win_amd64.whl (6.7 MB) Collecting PyQt5-Qt5==5.15.2 (from -r requirements.txt (line 18)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/37/97/5d3b222b924fa2ed4c2488925155cd0b03fd5d09ee1cfcf7c553c11c9f66/PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB) Collecting PyQt5-sip==12.10.1 (from -r requirements.txt (line 19)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f7/83/eecd013e3d38648e54a63ffe85639a481a14e09f4e75423968e915196937/PyQt5_sip-12.10.1-cp39-cp39-win_amd64.whl (77 kB) Collecting python-dateutil==2.8.2 (from -r requirements.txt (line 20)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB) Collecting pywin32-ctypes==0.2.0 (from -r requirements.txt (line 21)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9e/4b/3ab2720f1fa4b4bc924ef1932b842edf10007e4547ea8157b0b9fc78599a/pywin32_ctypes-0.2.0-py2.py3-none-any.whl (28 kB) Collecting six==1.16.0 (from -r requirements.txt (line 22)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB) Collecting typing_extensions==4.2.0 (from -r requirements.txt (line 23)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/75/e1/932e06004039dd670c9d5e1df0cd606bf46e29a28e65d5bb28e894ea29c9/typing_extensions-4.2.0-py3-none-any.whl (24 kB) Collecting zipp==3.8.0 (from -r requirements.txt (line 24)) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/80/0e/16a7ee38617aab6a624e95948d314097cc2669edae9b02ded53309941cfc/zipp-3.8.0-py3-none-any.whl (5.4 kB) Requirement already satisfied: setuptools in d:\ocr\aw\.venv1\lib\site-packages (from pyinstaller==5.1->-r requirements.txt (line 14)) (68.2.0) Building wheels for collected packages: dlib Building wheel for dlib (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [60 lines of output] running bdist_wheel running build running build_py running build_ext C:\Users\Admin\AppData\Local\Temp\pip-install-o09thgtz\dlib_63c12b5a1a2f485aaf617ed09e75027e\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.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\Admin\AppData\Local\Temp\pip-install-o09thgtz\dlib_63c12b5a1a2f485aaf617ed09e75027e\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Admin\AppData\Local\Temp\pip-install-o09thgtz\d lib_63c12b5a1a2f485aaf617ed09e75027e\build\lib.win-amd64-cpython-39 -DPYTHON_EXECUTABLE=D:\OCR\AW\.venv1\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Admin\AppData\Local\Temp\pip-install-o09thgtz\dlib_63c12b5a1a2f485aaf617ed09e75027e\build\lib.win-amd64-cpython-39 -A x64' -- Building for: Visual Studio 17 2022 CMake Error at CMakeLists.txt:2 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 3.5 has been removed from CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway. -- Configuring incomplete, errors occurred! Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "C:\Users\Admin\AppData\Local\Temp\pip-install-o09thgtz\dlib_63c12b5a1a2f485aaf617ed09e75027e\setup.py", line 222, in <module> setup( File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\__init__.py", line 103, in setup return distutils.core.setup(**attrs) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\core.py", line 185, in setup return run_commands(dist) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands dist.run_commands() File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands self.run_command(cmd) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\dist.py", line 1001, in run_command super().run_command(command) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "D:\OCR\AW\.venv1\lib\site-packages\wheel\bdist_wheel.py", line 364, in run self.run_command("build") File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command self.distribution.run_command(command) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\dist.py", line 1001, in run_command super().run_command(command) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run self.run_command(cmd_name) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command self.distribution.run_command(command) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\dist.py", line 1001, in run_command super().run_command(command) File "D:\OCR\AW\.venv1\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "C:\Users\Admin\AppData\Local\Temp\pip-install-o09thgtz\dlib_63c12b5a1a2f485aaf617ed09e75027e\setup.py", line 134, in run self.build_extension(ext) File "C:\Users\Admin\AppData\Local\Temp\pip-install-o09thgtz\dlib_63c12b5a1a2f485aaf617ed09e75027e\setup.py", line 171, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 373, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-o09thgtz\\dlib_63c12b5a1a2f485aaf617ed09e75027e\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Admin\\AppD ata\\Local\\Temp\\pip-install-o09thgtz\\dlib_63c12b5a1a2f485aaf617ed09e75027e\\build\\lib.win-amd64-cpython-39', '-DPYTHON_EXECUTABLE=D:\\OCR\\AW\\.venv1\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-o09thgtz\\dlib_63c12b5a1a2f485aaf617ed09e75027e\\build\\lib.win-amd64-cpython-39', '-A', 'x64']' returned non-zero exit status 1. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects [notice] A new release of pip is available: 23.2.1 -> 25.1.1 [notice] To update, run: python.exe -m pip install --upgrade pip (.venv1) PS D:\OCR\AW> 怎么办
时间: 2025-08-02 18:34:25 浏览: 12
<think>我们正在解决在Windows环境下使用pip安装dlib时出现的CMake版本不兼容问题。根据引用[1],在安装dlib时,pip会尝试使用CMake来构建dlib。错误信息中显示了CMake的调用命令,这表示安装过程中需要CMake。引用[2]和引用[3]提供了解决方案:先安装cmake(通过pip安装),然后再安装dlib。同时,建议使用清华的镜像源来加速安装。引用[3]还特别指定了dlib的版本为19.24.0,这可能是一个在Windows上兼容性较好的版本。因此,我们可以按照以下步骤操作:步骤1:确保已安装最新版本的pip在命令行中运行:python-mpipinstall--upgradepip步骤2:安装CMake(通过pip安装)使用清华镜像源安装cmake:pipinstallcmake-ihttps://pypi.tuna.tsinghua.edu.cn/simple步骤3:安装dlib可以尝试安装指定版本的dlib(如19.24.0)以提高兼容性:pipinstalldlib==19.24.0-ihttps://pypi.tuna.tsinghua.edu.cn/simple或者安装最新版本(如果不指定版本):pipinstalldlib-ihttps://pypi.tuna.tsinghua.edu.cn/simple注意:如果使用的是32位Python,需要确保安装的dlib版本有对应的预编译轮子(wheel)或者能够成功编译。在Windows上,对于32位Python,编译可能会遇到更多问题,因此建议使用64位Python。另外,引用[4]中显示了一段代码,但似乎与安装问题无关,可以忽略。如果上述步骤仍然失败,可能需要考虑以下额外步骤:1.确保已安装VisualStudioBuildTools(特别是C++桌面开发组件),因为dlib需要C++编译器。2.确保系统中安装了正确版本的CMake(除了通过pip安装的cmake,有时还需要系统安装CMake并将其添加到环境变量)。但是,根据引用[2]和[3],通过pip安装cmake通常就足够了。总结:主要步骤是先安装cmake,再安装dlib,并使用清华镜像源加速。下面我们以命令行的形式展示步骤:</think>### 解决Windows环境下pip安装dlib的CMake兼容问题
在Windows系统使用`pip install dlib`时出现CMake版本不兼容问题,通常是由于缺少编译依赖或环境配置不当导致。以下是已验证的解决方案:
#### 核心解决步骤
1. **安装必备编译工具**
安装Visual Studio Build Tools(选择"C++桌面开发"工作负载),确保包含MSVC编译器和Windows SDK[^1][^3]。
2. **通过pip安装CMake**
```bash
pip install cmake -i https://pypi.tuna.tsinghua.edu.cn/simple
```
使用清华镜像源确保成功安装最新CMake[^2][^3]。
3. **安装兼容版dlib**
```bash
pip install dlib==19.24.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
```
指定较稳定的19.24.0版本可避免新版本兼容问题[^3]。
#### 验证安装
```python
import dlib
print(dlib.__version__) # 应输出"19.24.0"
```
#### 常见问题排查
- **错误:CMake not found**
将CMake添加到系统PATH:安装后找到`cmake.exe`路径(通常在`Python\Scripts\`),添加到环境变量[^1]。
- **错误:C++编译器缺失**
检查Visual Studio Build Tools是否包含以下组件:
✓ MSVC v143 - VS 2022 C++工具集
✓ Windows 10/11 SDK
✓ C++ CMake工具[^1]
- **网络超时问题**
使用镜像源参数 `-i https://pypi.tuna.tsinghua.edu.cn/simple` 加速下载[^2][^3]。
#### 替代方案
若仍失败,可尝试:
```bash
pip install dlib --only-binary :all: # 强制使用预编译二进制
```
> **关键提示**:dlib 19.24.0在Windows Python 3.6-3.9环境验证通过,更高版本Python建议使用预编译wheel[^3]。
阅读全文
相关推荐


















