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

时间:2018-04-08 15:42:04

标签: python-3.x pip dlib

我正在尝试在Windows环境中安装face_recognition,但在尝试安装dlib时显示错误。因此,我尝试使用

从命令提示符单独安装dlib
pip install dlib

但它再次显示以下错误。我已经安装了cmake和boost但没有任何反应。

Collecting dlib
  Using cached dlib-19.10.0.tar.gz
Installing collected packages: dlib
  Running setup.py install for dlib ... error
    Complete output from command "c:\program files (x86)\python36-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\HP\\AppData\\Local\\Temp\\pip-build-rln5gr2k\\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\HP\AppData\Local\Temp\pip-8m0ix2fi-record\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
    Invoking CMake setup: 'cmake C:\Users\HP\AppData\Local\Temp\pip-build-rln5gr2k\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\HP\AppData\Local\Temp\pip-build-rln5gr2k\dlib\build\lib.win32-3.6 -DPYTHON_EXECUTABLE=c:\program files (x86)\python36-32\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\HP\AppData\Local\Temp\pip-build-rln5gr2k\dlib\build\lib.win32-3.6'
    -- Building for: Visual Studio 15 2017
    -- Selecting Windows SDK version 10.0.15063.0 to target Windows 10.0.16299.
    -- The C compiler identification is MSVC 19.10.25019.0
    -- The CXX compiler identification is MSVC 19.10.25019.0
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found PythonInterp: C:/Program Files (x86)/Python36-32/python.exe (found version "3.6.5")
    -- Found PythonLibs: C:/Program Files (x86)/Python36-32/libs/Python36.lib
    -- pybind11 v2.2.2
    -- ******************************************************************************************
    -- Your version of Visual Studio has incomplete C++11 support and is unable to compile the
    -- DNN examples. So we are disabling the deep learning tools.  If you want to use the DNN
    -- tools in dlib then update your copy of Visual Studio.
    -- ******************************************************************************************
    -- Looking for sys/types.h
    -- Looking for sys/types.h - found
    -- Looking for stdint.h
    -- Looking for stdint.h - found
    -- Looking for stddef.h
    -- Looking for stddef.h - found
    -- Check size of void*
    -- Check size of void* - done
    -- Enabling SSE4 instructions
    -- Searching for BLAS and LAPACK
    -- Searching for BLAS and LAPACK
    -- Looking for pthread.h
    -- Looking for pthread.h - not found
    -- Found Threads: TRUE
    CUDA_TOOLKIT_ROOT_DIR not found or specified
    -- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5")
    -- *** Dlib CUDA support requires C++11 but your compiler doesn't support it. ***
    -- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA
    -- C++11 activated.
    CMake Error at CMakeLists.txt:43 (message):
      You have to use a version of Visual Studio that supports C++11.  As of
      December 2017, the only versions that have good enough C++11 support to
      compile the dlib Pyhton API is a fully updated Visual Studio 2015 or a
      fully updated Visual Studio 2017.  Older versions of either of these
      compilers have bad C++11 support and will fail to compile the Python
      extension.  ***SO UPDATE YOUR VISUAL STUDIO TO MAKE THIS ERROR GO AWAY***


    -- Configuring incomplete, errors occurred!
    See also "C:/Users/HP/AppData/Local/Temp/pip-build-rln5gr2k/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeOutput.log".
    See also "C:/Users/HP/AppData/Local/Temp/pip-build-rln5gr2k/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeError.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\HP\AppData\Local\Temp\pip-build-rln5gr2k\dlib\setup.py", line 249, in <module>
        'Topic :: Software Development',
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "c:\program files (x86)\python36-32\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\program files (x86)\python36-32\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "c:\program files (x86)\python36-32\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\program files (x86)\python36-32\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "c:\program files (x86)\python36-32\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\program files (x86)\python36-32\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "c:\program files (x86)\python36-32\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\program files (x86)\python36-32\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\program files (x86)\python36-32\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\HP\AppData\Local\Temp\pip-build-rln5gr2k\dlib\setup.py", line 129, in run
        self.build_extension(ext)
      File "C:\Users\HP\AppData\Local\Temp\pip-build-rln5gr2k\dlib\setup.py", line 163, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "c:\program files (x86)\python36-32\lib\subprocess.py", line 291, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-build-rln5gr2k\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\HP\\AppData\\Local\\Temp\\pip-build-rln5gr2k\\dlib\\build\\lib.win32-3.6', '-DPYTHON_EXECUTABLE=c:\\program files (x86)\\python36-32\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\HP\\AppData\\Local\\Temp\\pip-build-rln5gr2k\\dlib\\build\\lib.win32-3.6']' returned non-zero exit status 1.

    ----------------------------------------
Command ""c:\program files (x86)\python36-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\HP\\AppData\\Local\\Temp\\pip-build-rln5gr2k\\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\HP\AppData\Local\Temp\pip-8m0ix2fi-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\HP\AppData\Local\Temp\pip-build-rln5gr2k\dlib\

2 个答案:

答案 0 :(得分:1)

好的,我只是通过更新Visual Studio找到了解决方案。早期的构建没有完整的C ++ 11支持,因此通过更新它,dlib被编译而没有任何错误。

答案 1 :(得分:0)

所有您需要做的就是打开命令提示符,然后键入pip install dlib。如果这对您不起作用,请重新安装python,然后单击“环境变量”。这可能会解决问题。如果继续,请不要犹豫。