无法在Mac OS X上安装dlib

3

我正在按照这里的说明进行操作:http://www.pyimagesearch.com/2017/03/27/how-to-install-dlib/

逐行执行,除了安装python3的那一行。我创建了一个虚拟环境,在虚拟环境中执行了以下四个命令:

$ pip install numpy
$ pip install scipy
$ pip install scikit-image
$ pip install dlib

与说明不同,最后一行需要几秒钟而不是15分钟。 安装完成后,我打开了ipython并尝试import dlib,然后收到了这条消息:

----> 1 from .dlib import *
      2 __version__ = "19.4.0"

ImportError: dlopen(/Users/myname/Documents/camera-project/code/story-board/cv/lib/python2.7/site-packages/dlib/dlib.so, 2): Library not loaded: @rpath/libmkl_rt.dylib
  Referenced from: /Users/myname/Documents/camera-project/code/story-board/cv/lib/python2.7/site-packages/dlib/dlib.so
  Reason: image not found
我猜这意味着未正确安装,但我不确定哪里出了问题?此外,我应该补充说明,我的mac上没有安装anaconda,所以这不可能是问题所在。然而,今天早些时候我有安装过anaconda,并且可以毫无问题地加载dlib,可能是因为我运行的是由anaconda分发的python版本,而我认为dlib随anaconda一起发布。但是,anaconda分发的X11已损坏,所以我必须从系统完全删除anaconda并重新开始。 编辑 这是我安装dlib“成功”后收到的消息:
    :/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Installing collected packages: dlib
Successfully installed dlib-19.4.0
1个回答

阿里云服务器只需要99元/年,新老用户同享,点击查看详情
1
你可能需要安装cmake软件包。 当我试图在我的Mac虚拟环境中安装dlib时,出现了错误。
running bdist_wheel
  running build
  error: Cannot find cmake, ensure it is installed and in the path.
  You can install cmake on OSX using `sudo brew install cmake`.
  You can also specify its path with --cmake parameter.
我建议尝试使用以下命令安装CMake:

cmake

brew install cmake

我已经安装了 cmake,还有 boost 和 boost-python。 - xiaolingxiao
你在虚拟环境中安装了cmake吗?当你尝试运行pip install dlib时,有没有出现任何错误,或者它只是似乎非常快地安装? - cosinepenguin
我在虚拟环境之外安装了 cmakeboostboost-python。我成功地安装了 dlib,而且安装速度非常快。我已经编辑了上面的问题,以便展示快速安装后我收到的消息。 - xiaolingxiao
嗯。你是在Python2环境下运行 from .dlib import * __version__ = "19.4.0" 代码吗?我感到困惑,因为它似乎正在尝试在Python2.7中查找图像,但看起来你已经正确安装了所有内容。 - cosinepenguin
所以在我进入虚拟环境并打开ipython后,我所做的就是import dlib。然后错误就出现了。 - xiaolingxiao
好的,我想我对ipython和dlib不是很了解,但我会尝试在python3中运行导入语句。此外,我会尝试运行export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/cuda/lib:/usr/local/lib:/usr/lib:/Developer/NVIDIA/CUDA-7.0/lib:,因为似乎错误来自于Library not loaded: @rpath/libmkl_rt.dylib。当我在网上查找时,我发现了这个:Make runtest failure。希望这对你有用! - cosinepenguin

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