且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Mac上为Python安装dlib?

更新时间:2022-06-21 01:33:53

我认为错误消息还有很多,可能与CMake有关,要么安装不正确,要么与 pip3 install dlib不兼容.

I think there's more to the error message and it's probably related to CMake, either it's not installed properly or it's not compatible with the pip3 install dlib.

我建议使用 Homebrew 来安装Python3(包括pip3)和CMake.Homebrew管理可能依赖于系统相关工具,路径等的程序包,工具,库的安装.它还使您不必使用 sudo 在系统上安装程序.

I suggest using Homebrew to install Python3 (which includes pip3) and CMake. Homebrew manages the installation of packages, tools, libraries that might depend on system-related tools, paths, etc. It also prevents you from having to use sudo to install stuff on your system.

  1. 安装自制软件

  1. Install Homebrew

  • See the "Install Homebrew" section of https://brew.sh/
  • Basically:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

使用Homebrew安装Python3(和pip3)

Install Python3 (and pip3) using Homebrew

  • See https://docs.brew.sh/Homebrew-and-Python
  • See Homebrew's formula for the latest Python3 (python3.7, python3.8, python3.9)
  • Basically do one of the following:
$ brew install python@3.7  # or python@3.8 or python@3.9
$ brew install python@3    # get whichever is the latest version

检查Python安装

$ python3 -V
$ python3 -m pip -V

  • 使用Homebrew安装CMake

  • Install CMake using Homebrew

    • See https://formulae.brew.sh/formula/cmake
    • Basically:
    $ brew install cmake
    

  • 检查CMake安装

    $ brew info cmake
    $ cmake --version
    

  • 最后,使用 pip

    $ python3 -m pip install dlib
    


  • 如果您不想使用Homebrew(由于某种原因),可以尝试从以下位置使用安装程序(dmg或tar.gz)直接安装Mac版CMake: 查看全文