无法在Windows 10上安装dlib

时间:2018-06-21 14:06:02

标签: python pycharm dlib

尝试使用pycharm软件包管理器在Windows 10上安装dlib。 我安装了Numpy,opencv-python,setuptools和wheel。 尝试安装dlib,然后出现第一个错误,要求我安装CMake。

现在我得到了: (尝试安装Visual Studio,但没有效果。)

    Collecting dlib   Using cached https://files.pythonhosted.org/packages/d5/5c/aa64510aa354d562ecba7edecd500b020280741140e5d91ff5ec1c6f8289/dlib-19.13.1.tar.gz Building wheels for collected packages: dlib   Running setup.py bdist_wheel for dlib: started   Running setup.py bdist_wheel for dlib: finished with status 'error'   Complete output from command C:\Users\Tom\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\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\Tom\AppData\Local\Temp\pip-wheel-f_njkl2_ --python-tag cp36:  running bdist_wheel   running build   running build_py   package init file 'dlib\__init__.py' not found (or not a regular file)   warning: build_py: byte-compiling is disabled, skipping.
     running build_ext   Building extension for Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] Invoking CMake setup: 'cmake C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\tools\python
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\build\lib.win32-3.6
-DPYTHON_EXECUTABLE=C:\Users\Tom\venv\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\build\lib.win32-3.6'
-- Building for: NMake Makefiles   -- The C compiler identification is unknown   -- The CXX compiler identification is unknown   CMake Error in CMakeLists.txt:
    The CMAKE_C_COMPILER:

      cl

    is not a full path and was not found in the PATH.

    To use the NMake generator with Visual C++, cmake must be run from a shell
    that can use the compiler cl from the command line.  This environment is
    unable to invoke the cl compiler.  To fix this problem, run cmake from the
    Visual Studio Command Prompt (vcvarsall.bat).

    Tell CMake where to find the compiler by setting either the environment
    variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
    the compiler, or to the compiler name if it is in the PATH.

     CMake Error in CMakeLists.txt:
    The CMAKE_CXX_COMPILER:

      cl

    is not a full path and was not found in the PATH.

    To use the NMake generator with Visual C++, cmake must be run from a shell
    that can use the compiler cl from the command line.  This environment is
    unable to invoke the cl compiler.  To fix this problem, run cmake from the
    Visual Studio Command Prompt (vcvarsall.bat).

    Tell CMake where to find the compiler by setting either the environment
    variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
    to the compiler, or to the compiler name if it is in the PATH.

     -- Configuring incomplete, errors occurred!   See also "C:/Users/Tom/AppData/Local/Temp/pycharm-packaging/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeOutput.log". See also "C:/Users/Tom/AppData/Local/Temp/pycharm-packaging/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeError.log". Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 256, in <module>
      'Topic :: Software Development',
    File "C:\Users\Tom\venv\lib\site-packages\setuptools-39.1.0-py3.6.egg\setuptools\__init__.py", line 129, in setup
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "C:\Users\Tom\venv\lib\site-packages\wheel\bdist_wheel.py", line 202, in run
      self.run_command('build')
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 133, in run
      self.build_extension(ext)
    File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 169, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 291, in check_call
      raise CalledProcessError(retcode, cmd)   subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\build\\lib.win32-3.6', '-DPYTHON_EXECUTABLE=C:\\Users\\Tom\\venv\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\build\\lib.win32-3.6']' returned non-zero exit status 1.
     ----------------------------------------   Running setup.py clean for dlib Failed to build dlib Installing collected packages: dlib   Running setup.py install for dlib: started
    Running setup.py install for dlib: finished with status 'error'
    Complete output from command C:\Users\Tom\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\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\Tom\AppData\Local\Temp\pip-record-1kold5c8\install-record.txt
--single-version-externally-managed --compile --install-headers C:\Users\Tom\venv\include\site\python3.6\dlib:
    running install
    running build
    running build_py
    package init file 'dlib\__init__.py' not found (or not a regular file)
    warning: build_py: byte-compiling is disabled, skipping.

    running build_ext
    Building extension for Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]
    Invoking CMake setup: 'cmake C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\tools\python
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\build\lib.win32-3.6
-DPYTHON_EXECUTABLE=C:\Users\Tom\venv\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\build\lib.win32-3.6'
    -- Building for: NMake Makefiles
    -- The C compiler identification is unknown
    -- The CXX compiler identification is unknown
    CMake Error in CMakeLists.txt:
      The CMAKE_C_COMPILER:

        cl

      is not a full path and was not found in the PATH.

      To use the NMake generator with Visual C++, cmake must be run from a shell
      that can use the compiler cl from the command line.  This environment is
      unable to invoke the cl compiler.  To fix this problem, run cmake from the
      Visual Studio Command Prompt (vcvarsall.bat).

      Tell CMake where to find the compiler by setting either the environment
      variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
      the compiler, or to the compiler name if it is in the PATH.


    CMake Error in CMakeLists.txt:
      The CMAKE_CXX_COMPILER:

        cl

      is not a full path and was not found in the PATH.

      To use the NMake generator with Visual C++, cmake must be run from a shell
      that can use the compiler cl from the command line.  This environment is
      unable to invoke the cl compiler.  To fix this problem, run cmake from the
      Visual Studio Command Prompt (vcvarsall.bat).

      Tell CMake where to find the compiler by setting either the environment
      variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
      to the compiler, or to the compiler name if it is in the PATH.


    -- Configuring incomplete, errors occurred!
    See also "C:/Users/Tom/AppData/Local/Temp/pycharm-packaging/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeOutput.log".
    See also "C:/Users/Tom/AppData/Local/Temp/pycharm-packaging/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeError.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 256, in <module>
        'Topic :: Software Development',
      File "C:\Users\Tom\venv\lib\site-packages\setuptools-39.1.0-py3.6.egg\setuptools\__init__.py", line 129, in setup
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Tom\venv\lib\site-packages\setuptools-39.1.0-py3.6.egg\setuptools\command\install.py", line 61, in run
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 133, in run
        self.build_extension(ext)
      File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 169, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 291, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\build\\lib.win32-3.6', '-DPYTHON_EXECUTABLE=C:\\Users\\Tom\\venv\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\build\\lib.win32-3.6']' returned non-zero exit status 1.

    ----------------------------------------

  Failed building wheel for dlib Command "C:\Users\Tom\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\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\Tom\AppData\Local\Temp\pip-record-1kold5c8\install-record.txt
--single-version-externally-managed --compile --install-headers C:\Users\Tom\venv\include\site\python3.6\dlib" failed with error code 1 in C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\

我在这里想念什么? 我真的很困惑。

10 个答案:

答案 0 :(得分:3)

答案 1 :(得分:0)

错误告诉您答案。 CMAKE_C_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  To use the NMake generator with Visual C++, cmake must be run from a shell
  that can use the compiler cl from the command line.  This environment is
  unable to invoke the cl compiler.  To fix this problem, run cmake from the
  Visual Studio Command Prompt (vcvarsall.bat)."

尝试使用Visual Studio命令提示符进行编译。那里的路径也应该正确。

答案 2 :(得分:0)

我已按照以下步骤安装face_recognition(dlib):-

  1. 重新安装了Python 3.6.6(https://www.python.org/ftp/python/3.6.6/python-3.6.6-amd64.exe)。

  2. pip3安装cmake

  3. pip3安装dlib

  4. pip3安装face_recognition

对我有用。

答案 3 :(得分:0)

here是安装dlib和openCV的最佳方法。

它只是使用pip来执行所有安装。 人们对于Windows错过或犯错的主要事情是声明PATH变量,并将它们保存到PC中有效的地址(正确版本匹配除外)。上面的博客明确表示要使用的版本和PATH变量的声明。

只需三个步骤:-

  1. 安装anaconda
  2. 激活虚拟环境
  3. 使用openCV(或任何其他必需的软件包)安装dlibpip

答案 4 :(得分:0)

我知道这个问题是针对Windows的,但是如果有人正在Mac上寻找解决方案的机会,

尝试使用此命令,对我有用

点安装https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz#SHA256=92587c81b0165e933593f505fdf099dface0d0f8ec874b1d8655fc774598911f

答案 5 :(得分:0)

如果您的系统中已安装conda,请按照以下步骤操作:

  • conda create -n py36 python = 3.6
  • 激活py36
  • conda config-添加通道conda-forge
  • conda安装numpy
  • conda install scipy
  • conda安装dlib

答案 6 :(得分:0)

如果已安装Visual Studio,则需要确保已选择 Clang工具

也请使用命令提示符(cmd),并在 pip install dlib 时耐心等待,

Clang tools

答案 7 :(得分:0)

请按照以下步骤操作:

  1. 安装所需的Python版本

  2. https://cmake.org/download/安装cmake并在安装时将其添加到路径中

  3. https://visualstudio.microsoft.com/visual-cpp-build-tools安装Visual Studio,然后进行修改->单个组件->选择以下内容: (MSBuild / MSVC v142-VS 2019 C ++ x64 / x86构建工具(v14.27)/ C ++ 2019可再发行更新/ Windows的C ++ CMake工具/对v142构建工具的CLI / CLI支持(14.27)/ C ++ Clang-cl for v142构建工具(x64 / x86)/用于Windows的C ++ Clang编译器(10.0.0)/ Windows通用CRT SDK / MSVC v140-VS 2015 C ++生成工具(v14.00)/ Windows 10 SDK(10.0.19041.0)/ C ++ 2019可重新分发的MSM ))

  4. 打开Visual Studio并将新项目创建为cmake c ++

  5. 构建项目后,系统将提示您更新Windows 10 SDK

  6. 安装SDK更新

  7. 转到Windows终端

  8. pip install dlib

这对我来说很完美。

谢谢

答案 8 :(得分:-1)

在可通过键盘上的Alt + F12访问的终端中使用以下代码。

pip install dlib==19.8.1

你应该很好。

答案 9 :(得分:-1)

Linux错误解决方案

$ sudo apt-get install build-essential cmake
$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libboost-all-dev
$ pip3 install dilb