ModuleNotFoundError:没有名为"face_recognition"的模块 [英] ModuleNotFoundError: No module named 'face_recognition'
问题描述
import face_recognition
image = face_recognition.load_image_file("My_Image.png")
face_locations = face_recognition.face_locations(image)
print("I found {} face(s) in this photograph.".format(len(face_locations)
运行上述代码时,发现以下错误消息.
When I run above code, I've found following error message.
回溯(最近一次通话最后一次):文件"sample.py",位于第1行导入face_recognition
Traceback (most recent call last): File "sample.py", line 1, in import face_recognition
并且我检查了安装 face_recognition
库时是否发现以下错误消息.
And I've checked that I've found following error message when I've installed face_recognition
library.
pip install face_recognition
RuntimeError:
*******************************************************************
CMake must be installed to build the following extensions: dlib
*******************************************************************
----------------------------------------
Failed building wheel for dlib
Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib, Pillow, numpy, face-recognition-models, face-recognition
命令"/usr/local/opt/python/bin/python3.7 -u -c"导入设置工具,tokenize; 文件 ='/private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-install-gk35rom0/dlib/setup.py'; f = getattr(tokenize,'打开',打开)(文件);代码= f.read().replace('\ r \ n','\ n'); f.close(); exec(compile(code, file ,'exec')))安装--record/private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-record-3enjhgfq/install-record.txt--single-version-externally-managed --compile失败,错误代码为1/private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-install-gk35rom0/dlib/
Command "/usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;file='/private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-install-gk35rom0/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/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-record-3enjhgfq/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/lj/cyczw6r164b5f3q1dvmbbkfh0000gn/T/pip-install-gk35rom0/dlib/
我的python版本是 Python 3.7.1
,pip是/library/Python/2.7/site-packages/pip(python 2.7)中的 pip 19.0.3
My python version is Python 3.7.1
and pip is pip 19.0.3 from /Library/Python/2.7/site-packages/pip (python 2.7)
推荐答案
使用以下命令安装Cmake:
Install Cmake with:
sudo apt install cmake
对于python3,不要单独使用 pip
,请使用 pip3
安装将来的python3模块:
And for python3 don't use pip
alone, use pip3
to install future python3 modules:
pip3安装face_recognition
这篇关于ModuleNotFoundError:没有名为"face_recognition"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!