如何在Mac上为Python安装dlib? [英] How to install dlib for python on mac?
问题描述
尝试在macOS上的Python 3.7上安装dlib时出现错误
I'm getting an error when trying to install dlib on Python 3.7 on macOS with
pip3 install dlib
我已经安装了CMake,所以这不是问题.
我收到以下错误消息:
I have installed CMake, so that is not the problem.
I'm getting these error messages:
Failed building wheel for dlib
和
Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/j2/nvk5521j2vn9s1w95_0vlwkm0000gn/T/pip-install-ls2e_3mr/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 /private/var/folders/j2/nvk5521j2vn9s1w95_0vlwkm0000gn/T/pip-record-hy3hu262/install-record.txt --single-version-externally-managed --compile"
failed with error code 1 in /private/var/folders/j2/nvk5521j2vn9s1w95_0vlwkm0000gn/T/pip-install-ls2e_3mr/dlib/
以红色结尾.我需要dlib的原因是要安装face_recognition.
at the end in red. The reason I need dlib is to install face_recognition.
推荐答案
我认为错误消息还有很多,可能与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.
-
安装自制软件
Install Homebrew
- 请参见"安装自制软件"; https://brew.sh/
- 基本上:
- 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
- 请参见 https://docs.brew.sh/Homebrew-and-Python
- 有关最新Python3的信息,请参见Homebrew的公式( python3.7 , python3.8 ,
- 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: 查看全文