Python 3.9.1 的 dlib 安装错误。如何知道哪个版本兼容?

Posted

技术标签:

【中文标题】Python 3.9.1 的 dlib 安装错误。如何知道哪个版本兼容?【英文标题】:dlib installation error for Python 3.9.1. How to know which version is compatible? 【发布时间】:2021-07-20 01:16:24 【问题描述】:

我已经安装了 CMake,现在正在尝试为人脸识别项目安装 dlib。我看过一些视频,问题似乎来自兼容性问题。对于 Python 3.9.1 哪个版本的 dlib 更兼容?我尝试使用 pip 安装 dlib,手动下载它仍然显示以下错误:

WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>
distutils: c:\users\aviparna.biswas\appdata\local\programs\python\python39\Include\UNKNOWN
sysconfig: c:\users\aviparna.biswas\appdata\local\programs\python\python39\Include
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Collecting dlib
  Using cached dlib-19.22.0.tar.gz (7.4 MB)
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\aviparna.biswas\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\setup.py'"'"'; __file__='"'"'C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\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'"'"'))' bdist_wheel -d 'C:\Users\aviparna.biswas\AppData\Local\Temp\pip-wheel-nx3osnd3'  
       cwd: C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\
  Complete output (58 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
  Building extension for Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
  Invoking CMake setup: 'cmake C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\build\lib.win-amd64-3.9 -DPYTHON_EXECUTABLE=c:\users\aviparna.biswas\appdata\local\programs\python\python39\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\build\lib.win-amd64-3.9 -A x64'
  -- 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 "<string>", line 1, in <module>
    File "C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\setup.py", line 222, in <module>
      setup(
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\site-packages\setuptools\__init__.py", line 165, 
in setup
      return distutils.core.setup(**attrs)
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\dist.py", line 966, in run_commands    
      self.run_command(cmd)
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command     
      cmd_obj.run()
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command      
      self.distribution.run_command(command)
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command     
      cmd_obj.run()
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\command\build.py", line 135, in run    
      self.run_command(cmd_name)
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command      
      self.distribution.run_command(command)
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command     
      cmd_obj.run()
    File "C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\setup.py", line 134, in run
      self.build_extension(ext)
    File "C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\setup.py", line 171, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\subprocess.py", line 373, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\build\\lib.win-amd64-3.9', '-DPYTHON_EXECUTABLE=c:\\users\\aviparna.biswas\\appdata\\local\\programs\\python\\python39\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\build\\lib.win-amd64-3.9', '-A', 'x64']' returned non-zero exit status 1.
  ----------------------------------------
  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: Command errored out with exit status 1:
     command: 'c:\users\aviparna.biswas\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\setup.py'"'"'; __file__='"'"'C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\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\aviparna.biswas\AppData\Local\Temp\pip-record-prgz7cvz\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\aviparna.biswas\appdata\local\programs\python\python39\Include\dlib'
         cwd: C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\
    Complete output (60 lines):
    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
    Building extension for Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
    Invoking CMake setup: 'cmake C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\build\lib.win-amd64-3.9 -DPYTHON_EXECUTABLE=c:\users\aviparna.biswas\appdata\local\programs\python\python39\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\build\lib.win-amd64-3.9 -A x64'
    -- 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 "<string>", line 1, in <module>
      File "C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\setup.py", line 222, in <module>
        setup(
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\site-packages\setuptools\__init__.py", line 165, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\dist.py", line 966, in run_commands  
        self.run_command(cmd)
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command   
        cmd_obj.run()
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\command\install.py", line 546, in run
        self.run_command('build')
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command    
        self.distribution.run_command(command)
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command   
        cmd_obj.run()
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\command\build.py", line 135, in run  
        self.run_command(cmd_name)
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command    
        self.distribution.run_command(command)
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command   
        cmd_obj.run()
      File "C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\setup.py", line 134, in run
        self.build_extension(ext)
      File "C:\Users\aviparna.biswas\AppData\Local\Temp\pip-install-1u1dh1_j\dlib_0e99482dc2db4cb5a05e1507ea95d200\setup.py", line 171, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "c:\users\aviparna.biswas\appdata\local\programs\python\python39\lib\subprocess.py", line 373, in check_call        
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\build\\lib.win-amd64-3.9', '-DPYTHON_EXECUTABLE=c:\\users\\aviparna.biswas\\appdata\\local\\programs\\python\\python39\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\build\\lib.win-amd64-3.9', '-A', 'x64']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\aviparna.biswas\appdata\local\programs\python\python39\python.exe' -u 
-c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\setup.py'"'"'; __file__='"'"'C:\\Users\\aviparna.biswas\\AppData\\Local\\Temp\\pip-install-1u1dh1_j\\dlib_0e99482dc2db4cb5a05e1507ea95d200\\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\aviparna.biswas\AppData\Local\Temp\pip-record-prgz7cvz\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\aviparna.biswas\appdata\local\programs\python\python39\Include\dlib' Check the logs for full command output.```

【问题讨论】:

错误消息是关于您的计算机上缺少 Visual Studio。这与“兼容性”毫无共同之处。快速搜索错误消息给出了这个问题:***.com/questions/63648184/…。 这能回答你的问题吗? Error in installing face_recognition module using pip 【参考方案1】:

https://github.com/shashankx86/dlib_compiled

I have compiled dlib from source for python 3.9
You can use this

【讨论】:

【参考方案2】:

安装 Cmake、dlib 和人脸识别对我有用:

    首先我从这个链接下载了 Visual Studio C++ https://visualstudio.microsoft.com/thank-you-for-downloading-visual-studio-for-cplusplus/?sku=Community&rel=16&rid=30005

    然后我下载 Cmake,dlib 然后 face_recognition。

picture

【讨论】:

这并没有提供问题的答案。一旦你有足够的reputation,你就可以comment on any post;相反,provide answers that don't require clarification from the asker.

以上是关于Python 3.9.1 的 dlib 安装错误。如何知道哪个版本兼容?的主要内容,如果未能解决你的问题,请参考以下文章

Python Face_Recognition - Cmake | Dlib 安装错误窗口

如何解决安装 Dlib 的错误?

dlib库,怎么在python中安装

dlib安装python 2.7

如何提高python下的dlib人脸检测速度

在 Windows 10 上为 python3 安装 dlib 时出错