ubuntu16.04インストールdlib

依存ライブラリのインストールのしやすさは、多くの場合、個人的な運の問題です。単純なpip install xxまたはapt-get install xxが成功する場合もあれば、生と死の穴となる場合もあり、さまざまなエラーが報告されます。私は深い穴に落ちたばかりで、1日投げた後、オンラインでさまざまな解決策を見つけましたが、幸いにもようやくクロールしました。私の方法があなたに役立つなら、褒めてください、ありがとう

設置環境
 

pip version:19.3.1
python version:3.7.4
cmake version:3.15.3
gcc version:5.5.0
OS version:ubuntu16.04

インストール方法:

pip install dlib==19.17.0

ここではバージョン19.17.0を使用していますが、最新バージョン19.18.0を使用することもできます。新しいバージョンのpython3.5、3.6、または3.7を使用しているため、新しいバージョンを使用してみてください。

使用できますが、19.7.0より前では使用しないでください。

運がよければ、上記のコマンド行を使用して正常にインストールできます。私のような次のエラーを報告した場合は、次のコマンドを使用してそれを解決できます(解決策は、dlib公式Webサイトから見つけることができます:http ://dlib.net /compile.html

sudo apt-get install libx11-dev

エラーは次のとおりです。

20171010
Collecting dlib==19.17.0
  Using cached https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/ailab/anaconda3/envs/py35/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wx78xd9i/dlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wx78xd9i/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 /tmp/pip-wheel-t7og5x5w --python-tag cp37
       cwd: /tmp/pip-install-wx78xd9i/dlib/
  Complete output (76 lines):
  20171010
  running bdist_wheel
  running build
  running build_py
  package init file 'dlib/__init__.py' not found (or not a regular file)
  running build_ext
  Building extension for Python 3.7.4 (default, Aug  9 2019, 18:51:30)
  Invoking CMake setup: 'cmake /tmp/pip-install-wx78xd9i/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-wx78xd9i/dlib/build/lib.linux-x86_64-3.7 -DPYTHON_EXECUTABLE=/home/ailab/anaconda3/envs/py35/bin/python -DCMAKE_BUILD_TYPE=Release'
  CMake Warning (dev) in CMakeLists.txt:
    No project() command is present.  The top-level CMakeLists.txt file must
    contain a literal, direct call to the project() command.  Add a line of
    code such as
  
      project(ProjectName)
  
    near the top of the file, but after cmake_minimum_required().
  
    CMake is pretending there is a "project(Project)" command on the first
    line.
  This warning is for project developers.  Use -Wno-dev to suppress it.
  
  -- The C compiler identification is GNU 5.5.0
  -- The CXX compiler identification is GNU 5.5.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found PythonInterp: /home/ailab/anaconda3/envs/py35/bin/python (found version "3.7.4")
  CMake Error at /tmp/pip-install-wx78xd9i/dlib/dlib/external/pybind11/tools/FindPythonLibsNew.cmake:122 (message):
    Python config failure: Python is 0-bit, chosen compiler is 64-bit
  Call Stack (most recent call first):
    /tmp/pip-install-wx78xd9i/dlib/dlib/external/pybind11/tools/pybind11Tools.cmake:16 (find_package)
    /tmp/pip-install-wx78xd9i/dlib/dlib/external/pybind11/CMakeLists.txt:33 (include)
  
  
  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-install-wx78xd9i/dlib/build/temp.linux-x86_64-3.7/CMakeFiles/CMakeOutput.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-wx78xd9i/dlib/setup.py", line 261, in <module>
      'Topic :: Software Development',
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
      return distutils.core.setup(**attrs)
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 192, in run
      self.run_command('build')
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-wx78xd9i/dlib/setup.py", line 135, in run
      self.build_extension(ext)
    File "/tmp/pip-install-wx78xd9i/dlib/setup.py", line 172, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "/home/ailab/anaconda3/envs/py35/lib/python3.7/subprocess.py", line 347, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-wx78xd9i/dlib/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-wx78xd9i/dlib/build/lib.linux-x86_64-3.7', '-DPYTHON_EXECUTABLE=/home/ailab/anaconda3/envs/py35/bin/python', '-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/ailab/anaconda3/envs/py35/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wx78xd9i/dlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wx78xd9i/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4j1ykojr/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-wx78xd9i/dlib/
    Complete output (78 lines):
    20171010
    running install
    running build
    running build_py
    package init file 'dlib/__init__.py' not found (or not a regular file)
    running build_ext
    Building extension for Python 3.7.4 (default, Aug  9 2019, 18:51:30)
    Invoking CMake setup: 'cmake /tmp/pip-install-wx78xd9i/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-wx78xd9i/dlib/build/lib.linux-x86_64-3.7 -DPYTHON_EXECUTABLE=/home/ailab/anaconda3/envs/py35/bin/python -DCMAKE_BUILD_TYPE=Release'
    CMake Warning (dev) in CMakeLists.txt:
      No project() command is present.  The top-level CMakeLists.txt file must
      contain a literal, direct call to the project() command.  Add a line of
      code such as
    
        project(ProjectName)
    
      near the top of the file, but after cmake_minimum_required().
    
      CMake is pretending there is a "project(Project)" command on the first
      line.
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- The C compiler identification is GNU 5.5.0
    -- The CXX compiler identification is GNU 5.5.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found PythonInterp: /home/ailab/anaconda3/envs/py35/bin/python (found version "3.7.4")
    CMake Error at /tmp/pip-install-wx78xd9i/dlib/dlib/external/pybind11/tools/FindPythonLibsNew.cmake:122 (message):
      Python config failure: Python is 0-bit, chosen compiler is 64-bit
    Call Stack (most recent call first):
      /tmp/pip-install-wx78xd9i/dlib/dlib/external/pybind11/tools/pybind11Tools.cmake:16 (find_package)
      /tmp/pip-install-wx78xd9i/dlib/dlib/external/pybind11/CMakeLists.txt:33 (include)
    
    
    -- Configuring incomplete, errors occurred!
    See also "/tmp/pip-install-wx78xd9i/dlib/build/temp.linux-x86_64-3.7/CMakeFiles/CMakeOutput.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-wx78xd9i/dlib/setup.py", line 261, in <module>
        'Topic :: Software Development',
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-wx78xd9i/dlib/setup.py", line 135, in run
        self.build_extension(ext)
      File "/tmp/pip-install-wx78xd9i/dlib/setup.py", line 172, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "/home/ailab/anaconda3/envs/py35/lib/python3.7/subprocess.py", line 347, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-wx78xd9i/dlib/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-wx78xd9i/dlib/build/lib.linux-x86_64-3.7', '-DPYTHON_EXECUTABLE=/home/ailab/anaconda3/envs/py35/bin/python', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/ailab/anaconda3/envs/py35/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wx78xd9i/dlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wx78xd9i/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4j1ykojr/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

さらに、python setup.py installを使用して上記と同様のエラーを報告する場合は、上記の解決策を使用して解決することもできます。特定のエラーについては、以下のリンクを参照してください。

https://github.com/davisking/dlib/issues/1903

私はもともとこの問題をdlibコードマネージャーに依頼したかったのですが、自分で解決したので、後で解決策を投稿しました。

おすすめ

転載: blog.csdn.net/qq_33391629/article/details/102687132