cmake 在Windows 10上为python安装Dlib时出错

2sbarzqh  于 2022-11-11  发布在  Windows
关注(0)|答案(2)|浏览(253)

我正在尝试安装dlib。我遵循了互联网上的每一个提示,但它就是不工作。我正在使用/尝试

  • 视窗10
  • cmake 3.21.4(它在路径上)
  • Python 3.8.12和3.6.4版本
  • 康达4.10.3
  • 第21.3.1条
  • 视觉工作室2019

我已经安装了conda和pip,尝试了两个与

  • pip安装dlib
  • pip安装dlib --详细信息
  • pip安装“一些url”
  • conda安装-c conda-forge数据库
  • conda安装-c conda-伪造/标签/cf201901 dlib

我得到的错误是:

Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 222, in <module>
        setup(
      File "c:\users\sophi\anaconda3\lib\site-packages\setuptools\__init__.py", line 159, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\sophi\anaconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\sophi\anaconda3\lib\site-packages\setuptools\command\install.py", line 68, in run
        return orig.install.run(self)
      File "c:\users\sophi\anaconda3\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "c:\users\sophi\anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\sophi\anaconda3\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\users\sophi\anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 134, in run
        self.build_extension(ext)
      File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 174, in build_extension
        subprocess.check_call(cmake_build, cwd=build_folder)
      File "c:\users\sophi\anaconda3\lib\subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1.
    Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1: 'c:\users\sophi\anaconda3\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\sophi\\AppData\\Local\\Temp\\pip-install-3w7lgrlb\\dlib_ffabe5e6a08e472b835f598e7803e3d4\\setup.py'"'"'; __file__='"'"'C:\\Users\\sophi\\AppData\\Local\\Temp\\pip-install-3w7lgrlb\\dlib_ffabe5e6a08e472b835f598e7803e3d4\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\sophi\AppData\Local\Temp\pip-record-kvd3vwdq\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\sophi\anaconda3\Include\dlib' Check the logs for full command output.

对我来说,这个问题似乎与cmake命令有关,但我不知道确切的问题是什么。我使用了pip install cmake和从源代码安装cmake,两者都不起作用。有人知道如何解决这个问题吗?

zujrkrfu

zujrkrfu1#

这可能是延迟响应,但我在尝试在Visual Studio代码上安装dlib时遇到了完全相同的问题。这是我在尝试运行命令“pip install dlib”时收到的错误。

Collecting dlib
Using cached dlib-19.23.1.tar.gz (7.4 MB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
  Running setup.py install for dlib ... error
  error: subprocess-exited-with-error

  × Running setup.py install for dlib did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      running install
      running build
      running build_py
      package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
      running build_ext

      ERROR: CMake must be installed to build dlib

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> dlib

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

因此,我的下一个方法是安装cmake,在那里安装工作,但我收到一个警告,文件路径到exe没有添加到我的路径。这导致当运行“cmake --version”输出在终端

'cmake' is not recognized as an internal or external command,
operable program or batch file.

我会怀疑运行不正确,为了解决这个问题,我只需要复制它在安装cmake后打印出来的路径到我的终端,然后进入高级系统设置-〉高级选项卡-〉环境变量-〉"您的桌面名称“的用户变量打开“路径”-〉单击新路径-〉粘贴路径
按照这些步骤运行命令“cmake --version”后,正确打印出版本install,这意味着它正在访问正确的路径。之后,“pip install dlib”工作正常,如下面的证明所示

Collecting dlib
  Using cached dlib-19.23.1.tar.gz (7.4 MB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
  Running setup.py install for dlib ... done
Successfully installed dlib-19.23.1

我希望这可能会有所帮助,因为这是一种对我安装dlib有效的方法。正如你提到的,你的cmake在路径上,我会通过运行命令来检查版本是否正确打印出来。

kokeuurv

kokeuurv2#

尽管我尝试测试了问题中提到的每种命令组合,但显然有一种组合我没有尝试:使用Python 3.6.4的Conda环境,然后

  • conda安装-c conda-forge数据库

Not able to install dlib on Windows 10 and Python 3.7正如Berkay所提到的,anaconda显然需要python〈=3.6.x,这为我解决了这个问题。!pip install dlib在这个环境中无法工作(可能是因为这个环境的另一个版本问题)!

相关问题