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

Posted

技术标签:

【中文标题】为啥我无法在我的 centos 上安装 dlib 库?【英文标题】:Why am I not able to install dlib library on my centos?为什么我无法在我的 centos 上安装 dlib 库? 【发布时间】:2021-10-18 07:49:22 【问题描述】:

我在没有 GPU 的 centos7 服务器上安装 dlib 时遇到问题。 我浏览了互联网,但找不到有效的解决方案。 我遇到的答案之一是问题是 Python 需要使用 --enable-shared 标志编译,以便 dlib 安装成功。 但显然这应该避免,因为它可能会导致其他问题。

这是我得到的错误。


  ERROR: Command errored out with exit status 1:
   command: /home/biotest/test2/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/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 /tmp/pip-wheel-nmjzjw_2
       cwd: /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/
  Complete output (76 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.6.8 (default, Nov 16 2020, 16:55:22)
  Invoking CMake setup: 'cmake /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/lib.linux-x86_64-3.6 -DPYTHON_EXECUTABLE=/home/biotest/test2/bin/python3 -DCMAKE_BUILD_TYPE=Release'
  -- The C compiler identification is GNU 4.8.5
  -- The CXX compiler identification is GNU 4.8.5
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found PythonInterp: /home/biotest/test2/bin/python3 (found version "3.6.8")
  -- Found PythonLibs: python3.6m
  -- Performing Test HAS_CPP14_FLAG
  -- Performing Test HAS_CPP14_FLAG - Failed
  -- Performing Test HAS_CPP11_FLAG
  -- Performing Test HAS_CPP11_FLAG - Success
  -- pybind11 v2.2.4
  -- Using CMake version: 3.21.1
  -- Compiling dlib version: 19.22.1
  CMake Error at /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/set_compiler_specific_options.cmake:50 (message):
    C++11 is required to use dlib, but the version of GCC you are using is too
    old and doesn't support C++11.  You need GCC 4.9 or newer.
  Call Stack (most recent call first):
    /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/test_for_sse4/CMakeLists.txt:8 (include)
 
 
  CMake Error at /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/check_if_sse4_instructions_executable_on_host.cmake:13 (try_compile):
    Failed to configure test project build system.
  Call Stack (most recent call first):
    /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/set_compiler_specific_options.cmake:13 (include)
    /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/CMakeLists.txt:33 (include)
 
 
  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeOutput.log".
  See also "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeError.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 261, in <module>
      'Topic :: Software Development',
    File "/home/biotest/test2/lib64/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/biotest/test2/lib64/python3.6/site-packages/wheel/bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/lib64/python3.6/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 134, in run
      self.build_extension(ext)
    File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 171, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "/usr/lib64/python3.6/subprocess.py", line 311, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/lib.linux-x86_64-3.6', '-DPYTHON_EXECUTABLE=/home/biotest/test2/bin/python3', '-DCMAKE_BUILD_TYPE=Release']' 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: /home/biotest/test2/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/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 /tmp/pip-record-sfiq9dha/install-record.txt --single-version-externally-managed --compile --install-headers /home/biotest/test2/include/site/python3.6/dlib
         cwd: /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/
    Complete output (78 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.6.8 (default, Nov 16 2020, 16:55:22)
    Invoking CMake setup: 'cmake /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/lib.linux-x86_64-3.6 -DPYTHON_EXECUTABLE=/home/biotest/test2/bin/python3 -DCMAKE_BUILD_TYPE=Release'
    -- The C compiler identification is GNU 4.8.5
    -- The CXX compiler identification is GNU 4.8.5
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found PythonInterp: /home/biotest/test2/bin/python3 (found version "3.6.8")
    -- Found PythonLibs: python3.6m
    -- Performing Test HAS_CPP14_FLAG
    -- Performing Test HAS_CPP14_FLAG - Failed
    -- Performing Test HAS_CPP11_FLAG
    -- Performing Test HAS_CPP11_FLAG - Success
    -- pybind11 v2.2.4
    -- Using CMake version: 3.21.1
    -- Compiling dlib version: 19.22.1
    CMake Error at /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/set_compiler_specific_options.cmake:50 (message):
      C++11 is required to use dlib, but the version of GCC you are using is too
      old and doesn't support C++11.  You need GCC 4.9 or newer.
    Call Stack (most recent call first):
      /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/test_for_sse4/CMakeLists.txt:8 (include)
   
   
    CMake Error at /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/check_if_sse4_instructions_executable_on_host.cmake:13 (try_compile):
      Failed to configure test project build system.
    Call Stack (most recent call first):
      /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/cmake_utils/set_compiler_specific_options.cmake:13 (include)
      /tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/dlib/CMakeLists.txt:33 (include)
   
   
    -- Configuring incomplete, errors occurred!
    See also "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeOutput.log".
    See also "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeError.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 261, in <module>
        'Topic :: Software Development',
      File "/home/biotest/test2/lib64/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/biotest/test2/lib64/python3.6/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib64/python3.6/distutils/command/install.py", line 556, in run
        self.run_command('build')
      File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib64/python3.6/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 134, in run
        self.build_extension(ext)
      File "/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py", line 171, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "/usr/lib64/python3.6/subprocess.py", line 311, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/build/lib.linux-x86_64-3.6', '-DPYTHON_EXECUTABLE=/home/biotest/test2/bin/python3', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/biotest/test2/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o9l2b5q2/dlib_40beddc2aee742ccaa15ab4582c22263/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 /tmp/pip-record-sfiq9dha/install-record.txt --single-version-externally-managed --compile --install-headers /home/biotest/test2/include/site/python3.6/dlib Check the logs for full command output.
(test2) [root@localhost biotest]#

【问题讨论】:

【参考方案1】:

也许你可以使用conda install dlib

conda install dlib

【讨论】:

以上是关于为啥我无法在我的 centos 上安装 dlib 库?的主要内容,如果未能解决你的问题,请参考以下文章

为啥我无法在 Anaconda 或 python 中正确安装 dlib

无法在 Python 3.6 中运行 dlib 模块

无法在 python 3 上安装 dlib

为啥 MySQLdb 安装无法在我的 64 位 Mac 上运行

为啥我在安装 dlib 时收到此错误“检查日志以获取完整的命令输出”?

在 Windows 10 上安装 dlib 的问题(已安装 Cmake)