在Windows 10上安装dlib失败

3

尝试使用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\

我在这里缺少什么?我真的感到困惑。

关于IT技术的问题,本文并没有提供足够的信息。

尝试这个解决方案 https://stackoverflow.com/questions/58777497/how-to-solve-issue-related-to-installation-of-dlib-on-windows-10/58857306#58857306 - MathanKumar
10个回答

14
pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f

尝试这个cmd命令,对我有效


1
非常感谢。这是我第一次成功了,我遵循了learnopencv的指示并尝试了许多dlib版本(安装了像cmake等依赖项)。 - JakeJ
1
请确保您的Python版本为3.6。它与3.7不兼容。 - Chamod Pathirana
这是针对dlib(19.19.0)的19.7.0版本的原始存储库链接吗? - Shiv948

5

你可以用pip安装cmake?这样就容易多了。(不幸的是,这仍然不够,你仍然需要安装Visual Studio 2015或更新版本,所以我还是卡住了,但至少其中一步已经处理好了。:-) - Synetech

3

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

  • conda create -n py36 python=3.6
  • activate py36
  • conda config --add channels conda-forge
  • conda install numpy
  • conda install scipy
  • conda install dlib

2
我知道这个问题是关于Windows的,但如果有人在Mac上遇到同样的问题,可以尝试以下命令,这对我很有效:
最初的回答
pip install https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz#SHA256=92587c81b0165e933593f505fdf099dface0d0f8ec874b1d8655fc774598911f

1
请按照以下步骤进行操作:

  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可再发行包更新/C++ Windows CMake工具/C++/CLI支持v142构建工具(14.27)/C++ Clang-cl for v142 build tools (x64/x86)/C++ Clang Compiler for Windows (10.0.0)/Windows通用CRT SDK/MSVC v140 - VS 2015 C++构建工具(v14.00)/Windows 10 SDK (10.0.19041.0)/C++ 2019可再发行包MSMs))

  4. 打开Visual Studio并创建新的CMake C++项目

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

  6. 安装SDK更新

  7. 进入Windows终端

  8. pip install dlib

这对我来说完美地运作了。

谢谢


1
如果您已经安装了Visual Studio,则需要确保选择了Clang工具 同时使用命令提示符(cmd),当pip install dlib时,请耐心等待,编译需要超过5分钟

Clang tools


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命令提示符进行编译。路径也应该是正确的。

0

安装dlib和openCV的最佳方法在这里给出。

它简单地使用pip执行所有安装操作。对于Windows系统,人们经常忽略或错误地声明PATH变量并将其保存到计算机上的有效地址,除了正确匹配版本。上述博客清楚地说明了要使用的版本和PATH变量的声明。

只需三个步骤:

  1. 安装anaconda
  2. 激活虚拟环境
  3. 使用pip(或任何其他所需软件包)安装openCVdlib

请在您的回答中提供所提供链接的主要要点。 - leopal
为什么在没有虚拟环境的情况下安装会抛出错误? - Banana Bamboo

0

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

2
这不是对这个问题的答案,因为该问题出现在Windows上,而提供的解决方案并不适用于Windows。请参阅https://stackoverflow.com/help/how-to-answer了解指南。 - kapad
他要求安装Windows 10操作系统。Linux是另一种操作系统。 - Definity

-3

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

pip install dlib==19.8.1

你应该可以开始了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接