opencv3.1.0+win7+64bit +vs2015配置

本文详细介绍了如何在Windows 7 64位系统上,使用Visual Studio 2015配置OpenCV 3.1.0。包括从官网下载,解压,设置VS项目的包含目录、库目录、链接器输入,以及解决配置过程中遇到的外部符号问题和运行时dll缺失问题。

1)官网下载opencv3.1.0

2)解压opencv3.1.0到任意文件夹,发现无x86文件夹,说明opencv3.1.0不支持32位系统

3)打开vs2015,新建项目,视图中找到属性管理器,双击“Microsoft.cpp.x64.user”,进行配置(这样可永久配置)

4)vc++目录下:包含目录配置:(根据opencv安装目录)

                            D:\software\opencv310\opencv\build\include;D:\software\opencv310\opencv\build\include\opencv;D:\software\opencv310\opencv\build\include\opencv2;

5)库目录:D:\software\opencv310\opencv\build\x64\vc14\lib;

6)链接器输入:opencv_world310d.lib;(debug)若要配置release版本,则是opencv_world310.lib;

7)配置完毕,进行测试

                    #include <opencv2\opencv.hpp>
                    using namespace cv;

                 void main()
                 {
                          Mat image = imread("1.jpg");
                           imshow("show", image);
                          waitKey(0);
                 }  




出现的问题:

1)无法解析的外部符号_winmain:等

     解决方案:在链接器-系统中,将子系统,由窗口改为控制台;

2)编译链接正确,运行时,出现:opencv配置完成无法启动程序丢失opencv_world310.dll.尝试重新安装此程序

 解决方案:将bin文件下的三个dll文件复制到c:windows/system32中

(.venv) 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 Requirement already satisfied: altgraph==0.17.2 in d:\ocr\aw\.venv\lib\site-packages (from -r requirements.txt (line 1)) (0.17.2) Requirement already satisfied: cycler==0.11.0 in d:\ocr\aw\.venv\lib\site-packages (from -r requirements.txt (line 2)) (0.11.0) Collecting dlib==19.23.0 (from -r requirements.txt (line 3)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/25/0f/05e70b2ebf6a539c4c397c7c3dd19b69e0b3d650443e12a8af4866f65b03/dlib-19.23.0.tar.gz (3.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 5.9 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Requirement already satisfied: fonttools==4.33.3 in d:\ocr\aw\.venv\lib\site-packages (from -r requirements.txt (line 4)) (4.33.3) Requirement already satisfied: future==0.18.2 in d:\ocr\aw\.venv\lib\site-packages (from -r requirements.txt (line 5)) (0.18.2) Requirement already satisfied: importlib-metadata==4.11.4 in d:\ocr\aw\.venv\lib\site-packages (from -r requirements.txt (line 6)) (4.11.4) Collecting kiwisolver==1.4.2 (from -r requirements.txt (line 7)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/97/2d/32ae1ce44d5b514dce568a809b3bed15d60ee1501b9fa9853a0fee705b59/kiwisolver-1.4.2-cp38-cp38-win_amd64.whl (55 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 55.4/55.4 kB 2.8 MB/s eta 0:00:00 Collecting matplotlib==3.5.2 (from -r requirements.txt (line 8)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2a/0d/bebf456dd3b5bb4ecd78cb1e78636f38716384529d083ed78327ba49ec83/matplotlib-3.5.2-cp38-cp38-win_amd64.whl (7.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.2/7.2 MB 35.4 MB/s eta 0:00:00 Collecting numpy==1.21.6 (from -r requirements.txt (line 9)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/48/5f/db4550e1c68206814a577ebd92c0dd082f3628fd7fc96725d44a521b0c92/numpy-1.21.6-cp38-cp38-win_amd64.whl (14.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.0/14.0 MB 31.2 MB/s eta 0:00:00 Collecting opencv-python==4.5.2.54 (from -r requirements.txt (line 10)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3e/ae/f0629a78fc5b631280664a91de8d2cee6e418790fec064e656897508fd33/opencv_python-4.5.2.54-cp38-cp38-win_amd64.whl (34.7 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 34.7/34.7 MB 31.2 MB/s eta 0:00:00 Collecting packaging==21.3 (from -r requirements.txt (line 11)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl (40 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 kB ? eta 0:00:00 Collecting pefile==2022.5.30 (from -r requirements.txt (line 12)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/48/30/4559d06bad5bb627733dac1ef28c34f5e35f1461247ba63e5f6366901277/pefile-2022.5.30.tar.gz (72 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 72.9/72.9 kB ? eta 0:00:00 Preparing metadata (setup.py) ... done Collecting Pillow==9.1.1 (from -r requirements.txt (line 13)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/71/54/bc24063ddb7ebb0962db41167971737f52351628907cf5c846f87d3501fc/Pillow-9.1.1-cp38-cp38-win_amd64.whl (3.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 41.4 MB/s eta 0:00:00 Collecting pyinstaller==5.1 (from -r requirements.txt (line 14)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/39/0c/fcedab1fc19e4a7b275c5298bb9c69e411d5092ceaf5a167b611de4c023d/pyinstaller-5.1-py3-none-win_amd64.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 24.5 MB/s eta 0:00:00 Collecting pyinstaller-hooks-contrib==2022.7 (from -r requirements.txt (line 15)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/de/97/9901350320f0454a04a937666235f532353c55507679cca9712464760431/pyinstaller_hooks_contrib-2022.7-py2.py3-none-any.whl (234 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 234.3/234.3 kB ? eta 0:00:00 Collecting pyparsing==3.0.9 (from -r requirements.txt (line 16)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6c/10/a7d0fa5baea8fe7b50f448ab742f26f52b80bfca85ac2be9d35cdd9a3246/pyparsing-3.0.9-py3-none-any.whl (98 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB ? eta 0:00:00 Collecting PyQt5==5.15.6 (from -r requirements.txt (line 17)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/be/f2/8e7b751d102ce3500cbeff97cb514eaf5c06d5e423676c37e9de28d0c06b/PyQt5-5.15.6-cp36-abi3-win_amd64.whl (6.7 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.7/6.7 MB 35.8 MB/s eta 0:00:00 Requirement already satisfied: PyQt5-Qt5==5.15.2 in d:\ocr\aw\.venv\lib\site-packages (from -r requirements.txt (line 18)) (5.15.2) Collecting PyQt5-sip==12.10.1 (from -r requirements.txt (line 19)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/39/d0/cf2b613a3309397013e7781f2cdb4b1e0661ae635d88b75b6f481ec43d8c/PyQt5_sip-12.10.1-cp38-cp38-win_amd64.whl (77 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.5/77.5 kB ? eta 0:00:00 Collecting python-dateutil==2.8.2 (from -r requirements.txt (line 20)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB ? eta 0:00:00 Collecting pywin32-ctypes==0.2.0 (from -r requirements.txt (line 21)) Downloading 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)) Downloading 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)) Downloading 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)) Downloading 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\.venv\lib\site-packages (from pyinstaller==5.1->-r requirements.txt (line 14)) (68.2.0) Building wheels for collected packages: dlib, pefile 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-ok58xrc7\dlib_85a29ad4d6b343a9b32725056a86ae46\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. if LooseVersion(cmake_version) < &#39;3.1.0&#39;: Building extension for Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] Invoking CMake setup: &#39;cmake C:\Users\Admin\AppData\Local\Temp\pip-install-ok58xrc7\dlib_85a29ad4d6b343a9b32725056a86ae46\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Admin\AppData\Local\Temp\pip-install-ok58xrc7\d lib_85a29ad4d6b343a9b32725056a86ae46\build\lib.win-amd64-cpython-38 -DPYTHON_EXECUTABLE=D:\OCR\AW\.venv\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Admin\AppData\Local\Temp\pip-install-ok58xrc7\dlib_85a29ad4d6b343a9b32725056a86ae46\build\lib.win-amd64-cpython-38 -A x64&#39; -- 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-ok58xrc7\dlib_85a29ad4d6b343a9b32725056a86ae46\setup.py", line 222, in <module> setup( File "D:\OCR\AW\.venv\lib\site-packages\setuptools\__init__.py", line 103, in setup return distutils.core.setup(**attrs) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\core.py", line 185, in setup return run_commands(dist) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands dist.run_commands() File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands self.run_command(cmd) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\dist.py", line 1001, in run_command super().run_command(command) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "D:\OCR\AW\.venv\lib\site-packages\wheel\bdist_wheel.py", line 364, in run self.run_command("build") File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command self.distribution.run_command(command) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\dist.py", line 1001, in run_command super().run_command(command) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run self.run_command(cmd_name) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command self.distribution.run_command(command) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\dist.py", line 1001, in run_command super().run_command(command) File "D:\OCR\AW\.venv\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "C:\Users\Admin\AppData\Local\Temp\pip-install-ok58xrc7\dlib_85a29ad4d6b343a9b32725056a86ae46\setup.py", line 134, in run self.build_extension(ext) File "C:\Users\Admin\AppData\Local\Temp\pip-install-ok58xrc7\dlib_85a29ad4d6b343a9b32725056a86ae46\setup.py", line 171, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 364, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command &#39;[&#39;cmake&#39;, &#39;C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-ok58xrc7\\dlib_85a29ad4d6b343a9b32725056a86ae46\\tools\\python&#39;, &#39;-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Admin\\AppD ata\\Local\\Temp\\pip-install-ok58xrc7\\dlib_85a29ad4d6b343a9b32725056a86ae46\\build\\lib.win-amd64-cpython-38&#39;, &#39;-DPYTHON_EXECUTABLE=D:\\OCR\\AW\\.venv\\Scripts\\python.exe&#39;, &#39;-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-ok58xrc7\\dlib_85a29ad4d6b343a9b32725056a86ae46\\build\\lib.win-amd64-cpython-38&#39;, &#39;-A&#39;, &#39;x64&#39;]&#39; 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 Building wheel for pefile (setup.py) ... done Created wheel for pefile: filename=pefile-2022.5.30-py3-none-any.whl size=69374 sha256=eb0fce74afadb696c631e077df35f2c9b633f4fa43fde26513600f71fd52c328 Stored in directory: c:\users\admin\appdata\local\pip\cache\wheels\c4\4d\66\e942afd74979c2f27949124de958fd59b790f2561e9d8ad952 Successfully built pefile 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.0.1 [notice] To update, run: python.exe -m pip install --upgrade pip (.venv) PS D:\OCR\AW> 这是什么错误
最新发布
06-13
<think>根据错误信息,安装dlib时失败。错误发生在构建dlib的wheel时。具体原因是CMake版本兼容性问题。错误信息指出:CMakeErroratCMakeLists.txt:2(CMAKE_MINIMUM_REQUIRED):CompatibilitywithCMake<3.5hasbeenremovedfromCMake.UpdatetheVERSIONargument<min>value.Or,usethe<min>...<max>syntaxtotellCMakethattheprojectrequiresatleast<min>buthasbeenupdatedtoworkwithpoliciesintroducedby<max>orearlier.Or,add-DCMAKE_POLICY_VERSION_MINIMUM=3.5totryconfiguringanyway.这意味着dlib的CMakeLists.txt要求的最低CMake版本过低,而当前系统安装的CMake版本已经移除了对旧版本的支持。解决方案:1.升级CMake到较新的版本(建议至少3.5以上)。2.或者,尝试在安装dlib时指定一个兼容的版本,因为dlib19.23.0可能对较新的CMake支持不好。可以尝试安装较新版本的dlib,比如19.24.0或更高。3.如果不想升级CMake,可以尝试安装预编译的dlibwheel(如果存在适用于你平台的版本)。但是,由于dlib是一个需要编译的C++库,通常需要自己编译。但是,从错误信息看,你的环境是Windows,Python3.8,64位。可以尝试从非官方的预编译二进制文件安装dlib。推荐使用ChristophGohlke提供的Windows预编译包。你可以从这里下载:https://www.lfd.uci.edu/~gohlke/pythonlibs/#dlib具体步骤:1.访问上述网站,搜索dlib。2.找到与你的Python版本和系统架构匹的版本。例如:dlib‑19.24.1‑cp38‑cp38‑win_amd64.whl(对应Python3.8,64位)。3.下载该文件,然后在命令行中进入该文件所在目录,使用pip安装:```bashpipinstalldlib‑19.24.1‑cp38‑cp38‑win_amd64.whl```另外,也可以尝试升级CMake。安装最新版本的CMake,并确保它在系统PATH中。升级CMake:-前往CMake官网下载最新版本:https://cmake.org/download/-安装后,将CMake的bin目录添加到系统环境变量PATH中。-重新打开命令行,运行`cmake--version`确认版本。然后重新运行`pipinstall-rrequirements.txt`但是,考虑到你的requirements.txt中指定了dlib==19.23.0,如果必须使用该版本,那么可能需要修改CMakeLists.txt(不推荐)或者使用兼容的CMake版本(3.5以下,但显然这不可行,因为新系统已经不支持旧CMake)。所以,更实际的做法是:1.升级CMake到最新版本(至少3.5以上)。2.如果仍然失败,尝试将dlib版本升级到较新的版本(如19.24.1),并修改requirements.txt中的版本号。由于你的requirements.txt中其他包可能也有版本要求,升级dlib版本可能会引起其他依赖问题,但dlib的更新通常向后兼容。因此,建议:-先尝试升级CMake,然后重新安装。-如果升级CMake后仍然失败,则尝试安装预编译的dlibwheel(如上所述)。-或者,在requirements.txt中将dlib版本改为较新的版本(如19.24.1),然后再次运行安装命令。注意:预编译的wheel可能会依赖特定的VisualC++Redistributable,请确保已安装。另外,错误信息中还提示了pip版本有更新,可以升级pip:```bashpython-mpipinstall--upgradepip```总结步骤:1.升级pip:`python-mpipinstall--upgradepip`2.升级CMake(下载安装最新版,并添加到PATH)。3.再次运行`pipinstall-rrequirements.txt-ihttps://pypi.tuna.tsinghua.edu.cn/simple`4.如果仍然失败,尝试下载预编译的dlibwheel进行安装,然后再次运行安装命令(跳过dlib的编译安装)。如果选择下载预编译的dlibwheel:-下载对应版本的whl文件(如dlib-19.24.1-cp38-cp38-win_amd64.whl)-然后使用pip安装该文件:`pipinstalldlib-19.24.1-cp38-cp38-win_amd64.whl`-然后再次运行`pipinstall-rrequirements.txt`,因为其他依赖还需要安装,但dlib已经安装,所以会跳过。或者,修改requirements.txt,将dlib==19.23.0改为dlib==19.24.1,然后再次运行安装命令(这样pip会尝试从PyPI安装新的dlib,可能已经有适用于你的平台的wheel,或者会重新编译,但新版本可能已经修复了CMake问题)。由于dlib19.23.0发布于2020年,而CMake在之后更新了,所以使用新版本CMake编译旧版dlib可能会有问题。因此,升级dlib版本可能是更好的选择。如果你无法解决,也可以考虑使用conda环境,因为conda可以管理C++依赖,可能更容易安装dlib。但是,根据问题描述,你使用的是venv。因此,建议尝试升级CMake和dlib版本。由于错误信息较长,这里只提供了关键解决方案。如果还有问题,请参考上述步骤。现在,针对你的问题,我给出一个具体的解决方案:升级CMake并修改dlib版本。步骤:1.升级CMake:下载并安装最新版CMake(如3.28或更高),安装时选择添加到PATH。2.修改requirements.txt中dlib的版本为19.24.1(或更高,目前最新为19.24.2)。3.重新运行安装命令。如果修改requirements.txt后仍然无法安装,则手动安装dlib的预编译版本,然后注释掉requirements.txt中的dlib行,再安装其他依赖。手动安装预编译dlib的示例命令(假设已下载whl文件):```bashpipinstalldlib-19.24.1-cp38-cp38-win_amd64.whl```然后修改requirements.txt,将dlib行注释掉(在前面加#),再运行:```bashpipinstall-rrequirements.txt-ihttps://pypi.tuna.tsinghua.edu.cn/simple```这样就不会再安装dlib(因为已经安装了),但会安装其他依赖。注意:确保下载的dlib版本与Python版本和系统架构一致。最后,如果所有方法都不行,可以考虑在Linux或MacOS下开发,或者使用Docker容器。希望这些解决方案能帮助你。如果问题仍然存在,请提供你的操作系统版本、CMake版本以及Python详细版本信息,以便进一步排查。</think>根据错误信息,安装 `dlib` 库时出现了构建失败的问题。以下是详细分析和解决方案: ### 错误原因分析 1. **CMake 版本兼容性问题**: - dlib 的构建脚本要求 CMake 最低版本为 3.5 - 当前系统中的 CMake 版本可能过旧或兼容策略变化导致失败 - 错误关键信息:`Compatibility with CMake < 3.5 has been removed` 2. **构建环境问题**: - dlib 需要 C++ 编译工具链(特别是 Windows 上的 Visual Studio 构建工具) - 环境中可能缺少必要的 C++ 开发依赖 3. **Python 环境问题**: - pip 版本较旧(23.2.1 → 建议升级到 25.0.1) - 可能存在 Python 环境冲突 --- ### 解决方案 #### 方法 1:安装预编译的 dlib(推荐) 绕过源码编译,直接安装预编译的 Windows 二进制包: ```bash # 先卸载已安装的错误版本 pip uninstall dlib # 安装预编译版本(指定 Python 3.8 兼容版本) pip install dlib==19.24.1 --only-binary=:all: -i https://pypi.tuna.tsinghua.edu.cn/simple ``` #### 方法 2:修复构建环境 如果必须从源码构建,需执行以下步骤: 1. **升级 CMake**: ```bash pip install --upgrade cmake ``` 或从官网下载最新 CMake:https://cmake.org/download/ 2. **安装 Visual Studio 构建工具**: - 下载并安装 [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) - 安装时勾选 "C++ 桌面开发" 组件 3. **升级 pip 并重试**: ```bash python -m pip install --upgrade pip pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple ``` #### 方法 3:使用 Conda 环境(替代方案) ```bash # 创建 Conda 环境 conda create -n myenv python=3.8 # 激活环境 conda activate myenv # 通过 Conda 安装 dlib(自动处理依赖) conda install -c conda-forge dlib=19.23 # 再安装其他依赖 pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple ``` --- ### 关键问题说明 1. **dlib 的特殊性**: - dlib 是 C++ 编写的机器学习库,需要本地编译环境 - Windows 上依赖 Visual Studio 的 C++ 编译工具链 2. **为什么预编译包更好**: - 避免本地编译的兼容性问题 - 节省安装时间(无需下载编译依赖) 3. **环境隔离建议**: - 使用虚拟环境(如 venv/Conda)避免系统环境污染 - 固定依赖版本(如 `dlib==19.24.1`) --- ### 验证安装 安装成功后运行验证: ```python import dlib print(dlib.__version__) # 应输出 19.24.1 或类似版本 ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值