在 Windows 上安装 Dlib 时出错(对于 python2)

Posted

技术标签:

【中文标题】在 Windows 上安装 Dlib 时出错(对于 python2)【英文标题】:Error when installing Dlib on Windows (for python2) 【发布时间】:2017-09-28 18:10:25 【问题描述】:

下午好,请帮帮我,我想在 windows 上安装 dlib for python,但是当我在 dlib dir 或 pip.exe install dlib 的 cmd 中写入 python.exe setup.py install 时,出现此错误:

CMake Warning at /usr/share/cmake-2.8.9/Modules/Platform/CYGWIN.cmake:15 (message):
  CMake no longer defines WIN32 on Cygwin!
  (1) If you are just trying to build this project, ignore this warning or
  quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
  the CMake cache.  If later configuration or build errors occur then this
  project may have been written under the assumption that Cygwin is WIN32.
  In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
  (2) If you are developing this project, add the line
    set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
  at the top of your top-level CMakeLists.txt file or set the minimum
  required version of CMake to 2.8.4 or higher.  Then teach your project to
  build on Cygwin without WIN32.
Call Stack (most recent call first):
  /usr/share/cmake-2.8.9/Modules/CMakeSystemSpecificInformation.cmake:36 (INCLUDE)
-- Check for working C compiler: /usr/bin/gcc.exe
-- Check for working C compiler: /usr/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:2 (CMAKE_MINIMUM_REQUIRED):
  CMake 2.8.12 or higher is required.  You are running version 2.8.9
-- Configuring incomplete, errors occurred!
error: cmake configuration failed!

我尝试使用 Cygwin 安装程序更新 cygwin 的 cmake,但 setup.py 使用旧版本的 cmake (2.8.9)。我尝试从 cygwin 的控制台运行 setup.py,但它没有看到 Boost(但它安装在我的计算机上)。我在 cygwin 中有这个错误:

-- 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++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Boost
CMake Error at /usr/share/cmake-3.3.2/Modules/FindPythonLibs.cmake:168    (file):
  file STRINGS file
  "/cygdrive/c/dlib-19.4/tools/python/C:/Python27/include/patchlevel.h"
cannot be read.
Call Stack (most recent call first):
  /cygdrive/c/dlib-19.4/dlib/cmake_utils/add_python_module:75 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
CMake Error at /usr/share/cmake-  3.3.2/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find PythonLibs: Found unsuitable version "", but required is at
  least "2.6" (found C:/Python27/libs/python27.lib)
Call Stack (most recent call first):
  /usr/share/cmake-3.3.2/Modules/FindPackageHandleStandardArgs.cmake:386   (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.3.2/Modules/FindPythonLibs.cmake:205   (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /cygdrive/c/dlib-19.4/dlib/cmake_utils/add_python_module:75 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
-- Configuring incomplete, errors occurred!
error: cmake configuration failed!

我可以更新 cygwin 的 cmake 以在 cmd 中使用它或让 cygwin 的终端看到 Boost 吗?

【问题讨论】:

【参考方案1】:

如果你有蟒蛇,你可以试试这个

conda install -c menpo dlib=18.18

我有很多问题,当我尝试用 pip 安装它时,但用 anaconda 就可以了

【讨论】:

谢谢,我会尽量做到的 很抱歉,也许我觉得不太好,但我对 Anaconda 有问题。当我尝试运行 conda.exe 时出现此错误。 UnicodeDecodeError: 'ascii' codec can't decode byte 0xcd in position 15: ordinal not in range(128) 我有 Windows 7、x32 和 2.7 python。我在 GitHub 上读到了这个问题,但解决它的所有方法都不适用于我。请帮帮我。

以上是关于在 Windows 上安装 Dlib 时出错(对于 python2)的主要内容,如果未能解决你的问题,请参考以下文章

在 Windows 10 上为 python 安装 Dlib 时出错

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

安装 dlib 时出错

为 python 安装 Dlib 库时出错

使用 GPU 支持安装 dlib 时出错

在 Windows 10 上安装 dlib