安装 dlib [重复]

Posted

技术标签:

【中文标题】安装 dlib [重复]【英文标题】:Installing dlib [duplicate] 【发布时间】:2021-10-16 07:38:21 【问题描述】:

我在this 之后为 python 3 安装 dlib,因为 pip 不起作用,我从源文件 (setup.py) 安装它。 但是,发生了错误:

-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:5 (message):



  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


  You must use Visual Studio to build a python extension on windows.  If you
  are getting this error it means you have not installed Visual C++.  Note
  that there are many flavors of Visual Studio, like Visual Studio for C#
  development.  You need to install Visual Studio for C++.


  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
  File "C:\Users\TIN\Downloads\dlib\dlib-19.22.0\setup.py", line 222, in <module>
    setup(
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install.py", line 67, in run
    self.do_egg_install()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\bdist_egg.py", line 164, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\bdist_egg.py", line 150, in call_command
    self.run_command(cmdname)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install_lib.py", line 11, in run
    self.build()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\command\install_lib.py", line 107, in build
    self.run_command('build_ext')
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\TIN\Downloads\dlib\dlib-19.22.0\setup.py", line 134, in run
    self.build_extension(ext)
  File "C:\Users\TIN\Downloads\dlib\dlib-19.22.0\setup.py", line 171, in build_extension
    subprocess.check_call(cmake_setup, cwd=build_folder)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\TIN\\Downloads\\dlib\\dlib-19.22.0\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\TIN\\Downloads\\dlib\\dlib-19.22.0\\build\\lib.win-amd64-3.9', '-DPYTHON_EXECUTABLE=C:\\Users\\TIN\\AppData\\Local\\Programs\\Python\\Python39\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\TIN\\Downloads\\dlib\\dlib-19.22.0\\build\\lib.win-amd64-3.9', '-A', 'x64']' returned non-zero exit status 1.

如何解决这个问题?另外,我使用的是 Python 3.9.4。而且,似乎我需要为 C++ 安装 Visual Studio。但是我在哪里可以找到呢?

【问题讨论】:

it seems like I need to install Visual Studio for C++. But where can I find that? → visualstudio.microsoft.com/vs/features/cplusplus 错误日志一目了然。您必须为“编译器、构建工具和运行时”安装 Visual Studio for C++,作为您提供的链接上@Rajat Bhatt 的答案。我相信你花在阅读所有答案上的时间肯定比写一个新问题 + 等待别人帮助的时间要短。 ***.com/… 【参考方案1】:

许多二进制文件依赖于 Microsoft Visual C++ Redistributable for Visual Studio 2015、2017 和 2019 for Python 3

所以,请尝试使用以下代码来解决它

pip install --upgrade setuptools

如果你没有成功解决这个问题,

那么你可以尝试使用这个链接The latest supported Visual C++ downloads来安装这个问题

【讨论】:

以上是关于安装 dlib [重复]的主要内容,如果未能解决你的问题,请参考以下文章

无法在 Windows 10 上安装 dlib

dlib 库未安装在 gcloud 上

安装 dlib 时出错

如何解决安装 Dlib 的错误?

dlib库,怎么在python中安装

ubuntu 安装dlib 出现dlib.so: undefined symbol: png_set_longjmp_fn