Dlib安装错误?

时间:2018-08-07 07:58:21

标签: python-3.x visual-studio cmake dlib

未安装Visual Studio 2015 在python中构建dlib之前,我已经安装了所有要求: Cmake

python 3.6和其他绑定。

使用pip安装dlib时:

pip install dlib

出现错误:

Collecting dlib
  Using cached https://files.pythonhosted.org/packages/df/aa/6a9bb2a763107bb2606d6ee1aa65fcd3b51375a9ef6436e9c9280b0dd63c/dlib-19.15.0.tar.gz
Building wheels for collected packages: dlib
  Running setup.py bdist_wheel for dlib ... error
  Complete output from command "c:\users\vikas tiwari\anaconda3\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\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 C:\Users\VIKAST~1\AppData\Local\Temp\pip-wheel-nnayeybw --python-tag cp36:
  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.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
  Invoking CMake setup: 'cmake C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\lib.win-amd64-3.6 -DPYTHON_EXECUTABLE=c:\users\vikas tiwari\anaconda3\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\lib.win-amd64-3.6 -A x64'
  -- Building for: Visual Studio 14 2015
  -- Selecting Windows SDK version  to target Windows 10.0.17134.
  CMake Error in CMakeLists.txt:
    Failed to run MSBuild command:

      C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe

    to get the value of VCTargetsPath:

      Microsoft (R) Build Engine version 14.0.25420.1
      Copyright (C) Microsoft Corporation. All rights reserved.

      Build started 8/7/2018 1:07:47 PM.
      Project "C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj" on node 1 (default targets).
      C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
      Done Building Project "C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj" (default targets) -- FAILED.

      Build FAILED.

      "C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj" (default target) (1) ->
        C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

          0 Warning(s)
          1 Error(s)

      Time Elapsed 00:00:00.03


    Exit code: 1



  -- Configuring incomplete, errors occurred!
  See also "C:/Users/Vikas Tiwari/AppData/Local/Temp/pip-install-4f4b8868/dlib/build/temp.win-amd64-3.6/Release/CMakeFiles/CMakeOutput.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\setup.py", line 257, in <module>
      'Topic :: Software Development',
    File "c:\users\vikas tiwari\anaconda3\lib\site-packages\setuptools\__init__.py", line 129, in setup
      return distutils.core.setup(**attrs)
    File "c:\users\vikas tiwari\anaconda3\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "c:\users\vikas tiwari\anaconda3\lib\distutils\dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "c:\users\vikas tiwari\anaconda3\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "c:\users\vikas tiwari\anaconda3\lib\site-packages\wheel\bdist_wheel.py", line 202, in run
      self.run_command('build')
    File "c:\users\vikas tiwari\anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\vikas tiwari\anaconda3\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "c:\users\vikas tiwari\anaconda3\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "c:\users\vikas tiwari\anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\vikas tiwari\anaconda3\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\setup.py", line 133, in run
      self.build_extension(ext)
    File "C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\setup.py", line 170, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "c:\users\vikas tiwari\anaconda3\lib\subprocess.py", line 291, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\dlib\\build\\lib.win-amd64-3.6', '-DPYTHON_EXECUTABLE=c:\\users\\vikas tiwari\\anaconda3\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\dlib\\build\\lib.win-amd64-3.6', '-A', 'x64']' returned non-zero exit status 1.

  ----------------------------------------
  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
    Complete output from command "c:\users\vikas tiwari\anaconda3\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\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 C:\Users\VIKAST~1\AppData\Local\Temp\pip-record-aol24hcc\install-record.txt --single-version-externally-managed --compile:
    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.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
    Invoking CMake setup: 'cmake C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\lib.win-amd64-3.6 -DPYTHON_EXECUTABLE=c:\users\vikas tiwari\anaconda3\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\lib.win-amd64-3.6 -A x64'
    -- Building for: Visual Studio 14 2015
    -- Selecting Windows SDK version  to target Windows 10.0.17134.
    CMake Error in CMakeLists.txt:
      Failed to run MSBuild command:

        C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe

      to get the value of VCTargetsPath:

        Microsoft (R) Build Engine version 14.0.25420.1
        Copyright (C) Microsoft Corporation. All rights reserved.

        Build started 8/7/2018 1:07:50 PM.
        Project "C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj" on node 1 (default targets).
        C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
        Done Building Project "C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj" (default targets) -- FAILED.

        Build FAILED.

        "C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj" (default target) (1) ->
          C:\Users\Vikas Tiwari\AppData\Local\Temp\pip-install-4f4b8868\dlib\build\temp.win-amd64-3.6\Release\CMakeFiles\3.12.0\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

            0 Warning(s)
            1 Error(s)

        Time Elapsed 00:00:00.03


      Exit code: 1



    -- Configuring incomplete, errors occurred!
    See also "C:/Users/Vikas Tiwari/AppData/Local/Temp/pip-install-4f4b8868/dlib/build/temp.win-amd64-3.6/Release/CMakeFiles/CMakeOutput.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\setup.py", line 257, in <module>
        'Topic :: Software Development',
      File "c:\users\vikas tiwari\anaconda3\lib\site-packages\setuptools\__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\users\vikas tiwari\anaconda3\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\vikas tiwari\anaconda3\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\setup.py", line 133, in run
        self.build_extension(ext)
      File "C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\setup.py", line 170, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "c:\users\vikas tiwari\anaconda3\lib\subprocess.py", line 291, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\dlib\\build\\lib.win-amd64-3.6', '-DPYTHON_EXECUTABLE=c:\\users\\vikas tiwari\\anaconda3\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\dlib\\build\\lib.win-amd64-3.6', '-A', 'x64']' returned non-zero exit status 1.

    ----------------------------------------
Command ""c:\users\vikas tiwari\anaconda3\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\VIKAST~1\\AppData\\Local\\Temp\\pip-install-4f4b8868\\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 C:\Users\VIKAST~1\AppData\Local\Temp\pip-record-aol24hcc\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\VIKAST~1\AppData\Local\Temp\pip-install-4f4b8868\dlib\

我真的不知道这里真正的问题是什么。我必须安装Visual Studio来编译dlib的c ++文件吗? 现在没有安装VS 2015!

3 个答案:

答案 0 :(得分:0)

您在这里:

  • cmake下载CMake并将其添加到PATH(C:\ Program Files \ CMake \ bin)
  • 使用pip安装dlib(pip install dlib == 19.4)

答案 1 :(得分:0)

忘记一切,尝试从头开始安装dlib和/或opencv here的方法。

这是一个非常简单的三步法

  1. 安装anaconda
  2. 使用cmd激活虚拟环境
  3. 使用pip通过cmd安装dlibopencv

您也可以连接到this线程。

答案 2 :(得分:0)

这是我解决同一问题的方法。

  1. 确保已安装cmake并将 CMAKE_FOLDER \ bin 添加到环境可变的环境中
  2. 安装anaconda
  3. 然后在anaconda shell中运行以下命令。

conda update conda

conda update anaconda

  1. 创建新环境conda create -n env_dlib python=3.6
  2. 激活环境conda activate env_dlib
  3. 安装dlib conda install -c conda-forge dlib

使用

验证您在python shell中的安装

import dlib dlib.__version__