使用 pip 安装 dlib 时遇到问题

Posted

技术标签:

【中文标题】使用 pip 安装 dlib 时遇到问题【英文标题】:trouble installing dlib with pip 【发布时间】:2021-01-16 19:47:30 【问题描述】:

我尝试使用 pip 下载 dlib,但结果如下:

Building wheel for dlib (setup.py) ... error


> ERROR: Command errored out with exit status 1:    command: 'c:\program
> files (x86)\python38-32\python.exe' -u -c 'import sys, setuptools,
> tokenize; sys.argv[0] =
> '"'"'C:\\Users\\kiddr\\AppData\\Local\\Temp\\pip-install-6dc0zubd\\dlib\\setup.py'"'"';
> __file__='"'"'C:\\Users\\kiddr\\AppData\\Local\\Temp\\pip-install-6dc0zubd\\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\kiddr\AppData\Local\Temp\pip-wheel-f242luxg'
>        cwd: C:\Users\kiddr\AppData\Local\Temp\pip-install-6dc0zubd\dlib\  
> Complete output (53 lines):   running bdist_wheel   running build  
> running build_py   package init file 'tools\python\dlib\__init__.py'
> not found (or not a regular file)   running build_ext   Traceback
> (most recent call last):
>     File "C:\Users\kiddr\AppData\Local\Temp\pip-install-6dc0zubd\dlib\setup.py",
> line 120, in get_cmake_version
>       out = subprocess.check_output(['cmake', '--version'])
>     File "c:\program files (x86)\python38-32\lib\subprocess.py", line 411, in check_output
>       return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
>     File "c:\program files (x86)\python38-32\lib\subprocess.py", line 489, in run
>       with Popen(*popenargs, **kwargs) as process:
>     File "c:\program files (x86)\python38-32\lib\subprocess.py", line 854, in __init__
>       self._execute_child(args, executable, preexec_fn, close_fds,
>     File "c:\program files (x86)\python38-32\lib\subprocess.py", line 1307, in _execute_child
>       hp, ht, pid, tid = _winapi.CreateProcess(executable, args,   FileNotFoundError: [WinError 2] The system cannot find the file
> specified
During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\kiddr\AppData\Local\Temp\pip-install-6dc0zubd\dlib\setup.py", line 223, in <module>
      setup(
    File "c:\program files (x86)\python38-32\lib\site-packages\setuptools\__init__.py", line 145, in setup
      return distutils.core.setup(**attrs)
    File "c:\program files (x86)\python38-32\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "c:\program files (x86)\python38-32\lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "c:\program files (x86)\python38-32\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\kiddr\AppData\Roaming\Python\Python38\site-packages\wheel\bdist_wheel.py", line 290, in run
      self.run_command('build')
    File "c:\program files (x86)\python38-32\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\program files (x86)\python38-32\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "c:\program files (x86)\python38-32\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "c:\program files (x86)\python38-32\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\program files (x86)\python38-32\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\kiddr\AppData\Local\Temp\pip-install-6dc0zubd\dlib\setup.py", line 129, in run
      cmake_version = self.get_cmake_version()
    File "C:\Users\kiddr\AppData\Local\Temp\pip-install-6dc0zubd\dlib\setup.py", line 122, in get_cmake_version
      raise RuntimeError("\n*******************************************************************\n" +
  RuntimeError:
  *******************************************************************
   CMake must be installed to build the following extensions: _dlib_pybind11
  *******************************************************************

  ----------------------------------------
  ERROR: Failed building wheel for dlib

这很奇怪,因为我确实安装了 CMake,甚至重新启动了我的电脑。我还将站点包的路径添加到我的 PATH 环境中。我还确保 pip 已升级到最新版本,并尝试从 github 手动下载 zip 版本并通过解压缩文件并以管理员身份运行 setup.py 来安装它。我遇到了完全相同的错误代码。

有人可以帮忙吗?提前非常感谢您!

【问题讨论】:

【参考方案1】:

1.使用python 3.6.9版本

2.首先安装cmake。

conda install -c anaconda cmake

使用这些命令安装 dlib

pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f 

【讨论】:

以上是关于使用 pip 安装 dlib 时遇到问题的主要内容,如果未能解决你的问题,请参考以下文章

使用 python3.5 安装 dlib 时遇到麻烦

当我尝试使用 pip 安装 Dlib 时出错。苹果系统

使用 pip 安装 Dlib 时出错

使用 pip 安装 TensorFlow 时遇到问题

使用 pip 安装私有 github 存储库时遇到问题

为啥我无法在我的 centos 上安装 dlib 库?