Windows10 Python安装dlib库失败

Tamara ·
更新时间:2024-11-13
· 669 次阅读

Windows10安装dlib失败的几点原因

因为学习Python需要,需要安装dlib库,踩了许多个坑,尝试了种种方法,那一片红色的报错依然刺眼,发现问题,寻找问题的根源,终于找到解决方法。

1.安装dlib前需要有依赖库,cmake和boost。
多简单的问题对不对?

pip install cmake pip install boost

潇洒回车,轻松安装好,然后

pip install dlib

潇洒回车,潇洒报错…

Collecting dlib Downloading https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz (3.4MB) |████████████████████████████████| 3.4MB 14kB/s Building wheels for collected packages: dlib Building wheel for dlib (setup.py) ... error ERROR: Complete output from command 'f:\python36\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\fu\\AppData\\Local\\Temp\\pip-install-t50q34ym\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\fu\AppData\Local\Temp\pip-wheel-g2i4oztb' --python-tag cp36: ERROR: running bdist_wheel running build running build_py package init file 'dlib\__init__.py' not found (or not a regular file) running build_ext Traceback (most recent call last): File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 120, in get_cmake_version out = subprocess.check_output(['cmake', '--version']) File "f:\python36\lib\subprocess.py", line 356, in check_output **kwargs).stdout File "f:\python36\lib\subprocess.py", line 423, in run with Popen(*popenargs, **kwargs) as process: File "f:\python36\lib\subprocess.py", line 729, in __init__ restore_signals, start_new_session) File "f:\python36\lib\subprocess.py", line 1017, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 261, in 'Topic :: Software Development', File "f:\python36\lib\site-packages\setuptools\__init__.py", line 143, in setup return distutils.core.setup(**attrs) File "f:\python36\lib\distutils\core.py", line 148, in setup dist.run_commands() File "f:\python36\lib\distutils\dist.py", line 955, in run_commands self.run_command(cmd) File "f:\python36\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "f:\python36\lib\site-packages\wheel\bdist_wheel.py", line 192, in run self.run_command('build') File "f:\python36\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "f:\python36\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "f:\python36\lib\distutils\command\build.py", line 135, in run self.run_command(cmd_name) File "f:\python36\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "f:\python36\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 129, in run cmake_version = self.get_cmake_version() File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 125, in get_cmake_version "\n*******************************************************************\n") RuntimeError: ******************************************************************* CMake must be installed to build the following extensions: dlib ******************************************************************* ---------------------------------------- ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib Installing collected packages: dlib Running setup.py install for dlib ... error ERROR: Complete output from command 'f:\python36\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\fu\\AppData\\Local\\Temp\\pip-install-t50q34ym\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\fu\AppData\Local\Temp\pip-record-4kwg7hfv\install-record.txt' --single-version-externally-managed --compile: ERROR: running install running build running build_py package init file 'dlib\__init__.py' not found (or not a regular file) running build_ext Traceback (most recent call last): File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 120, in get_cmake_version out = subprocess.check_output(['cmake', '--version']) File "f:\python36\lib\subprocess.py", line 356, in check_output **kwargs).stdout File "f:\python36\lib\subprocess.py", line 423, in run with Popen(*popenargs, **kwargs) as process: File "f:\python36\lib\subprocess.py", line 729, in __init__ restore_signals, start_new_session) File "f:\python36\lib\subprocess.py", line 1017, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 261, in 'Topic :: Software Development', File "f:\python36\lib\site-packages\setuptools\__init__.py", line 143, in setup return distutils.core.setup(**attrs) File "f:\python36\lib\distutils\core.py", line 148, in setup dist.run_commands() File "f:\python36\lib\distutils\dist.py", line 955, in run_commands self.run_command(cmd) File "f:\python36\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "f:\python36\lib\site-packages\setuptools\command\install.py", line 61, in run return orig.install.run(self) File "f:\python36\lib\distutils\command\install.py", line 545, in run self.run_command('build') File "f:\python36\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "f:\python36\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "f:\python36\lib\distutils\command\build.py", line 135, in run self.run_command(cmd_name) File "f:\python36\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "f:\python36\lib\distutils\dist.py", line 974, in run_command cmd_obj.run() File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 129, in run cmake_version = self.get_cmake_version() File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 125, in get_cmake_version "\n*******************************************************************\n") RuntimeError: ******************************************************************* CMake must be installed to build the following extensions: dlib ******************************************************************* ---------------------------------------- ERROR: Command "'f:\python36\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\fu\\AppData\\Local\\Temp\\pip-install-t50q34ym\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\fu\AppData\Local\Temp\pip-record-4kwg7hfv\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\ WARNING: You are using pip version 19.1, however version 19.1.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.

看看错误信息中有这个:

RuntimeError: ******************************************************************* CMake must be installed to build the following extensions: dlib *******************************************************************

我就奇怪,我不是已经安装好这个cmake了嘛,你怎么还是不行。
2.不仅要安装cmake,还要下载visual studio20xx,要有C++的环境
官方下载地址:Visual Studio 2019
看一下度娘对cmake的介绍:

CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。他能够输出各种各样的makefile或者project文件,能测试编译器所支持的C++特性,类似UNIX下的automake。只是
CMake 的组态档取名为 CMakeLists.txt。

编译工具,那应该要有编译环境啊。

刚开始配置的时候,我也发现要安装这个vs,那就装呗,装好,还是不行,因为我安装了vs在安装的时候…
在这里插入图片描述
还不知道这个cmake是什么时候,我想,既然是Python的库,那我就安装Python这个模块就可以了,硬盘空间寸土寸金,然后,那片红色依然刺眼,当事人表示非常后悔…所以,一定要点上C++那个模块。

最后

pip install dlib Looking in indexes: http://mirrors.aliyun.com/pypi/simple/ Processing c:\users\ccc\appdata\local\pip\cache\wheels\5f\8b\5d\aea9c00e6b02ac6ce8b91db2c607b51044718ae7a09c0963f1\dl ib-19.19.0-cp37-cp37m-win_amd64.whl Installing collected packages: dlib Successfully installed dlib-19.19.0

希望能够帮助你。


作者:cgy233



dlib windows10 windows Python

需要 登录 后方可回复, 如果你还没有账号请 注册新账号