已解决ImportError: No module named ‘face_recognition‘

这个问题搞了好久,网上的方法试了一圈,什么装cmake、装boost、更新pip、用conda装(没有找到包),都不适用我的问题。

用自动安装的指令:pip install face_recognition,一装就报错:

(tfenv) C:\Users\1>pip install face_recognition
Collecting face_recognition
  Downloading http://mirrors.aliyun.com/pypi/packages/1e/95/f6c9330f54ab07bfa032bf3715c12455a381083125d8880c43cbe76bb3d0/face_recognition-1.3.0-py2.py3-none-any.whl
Collecting dlib>=19.7 (from face_recognition)
  Downloading http://mirrors.aliyun.com/pypi/packages/f1/40/e407366816646bb452578997e6ca2140f004eec8f611e8512ee429ded2be/dlib-19.20.0.tar.gz (3.2MB)
    100% |████████████████████████████████| 3.2MB 10.2MB/s
Requirement already satisfied: numpy in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face_recognition)
Requirement already satisfied: face-recognition-models>=0.3.0 in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face_recognition)
Requirement already satisfied: Click>=6.0 in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face_recognition)
Requirement already satisfied: Pillow in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face_recognition)
Requirement already satisfied: olefile in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from Pillow->face_recognition)
Building wheels for collected packages: dlib
  Running setup.py bdist_wheel for dlib ... error

仔细看,这个指令执行一开始,就到阿里云网站下载一个叫:face_recognition-1.3.0-py2.py3-none-any.whl的东西。

还提示Collecting dlib>=19.7 (from face_recognition),但我的dlib版本是19.4的

突发奇想,会不会是版本适配的坑,因为pip下载不手动指定版本,一般默认下载最新版。。。

在网上找到,face_recognition的下载地址。

里面有很多版本的安装包。
已解决ImportError: No module named ‘face_recognition‘_第1张图片
找一个点进去,找一个对应自己python版本的包下载。

查看python的方法:在prompt终端中输入python,看到我的python是3.5.4的,所以1.2.3这个包不适合我。

(tfenv) D:\ProgramData\Anaconda3\envs\tfenv\Lib\site-packages>python
Python 3.5.4 |Anaconda custom (64-bit)| (default, Aug 14 2017, 13:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

再按ctrl+c退出python环境。

已解决ImportError: No module named ‘face_recognition‘_第2张图片
包下载好以后,我把他放在了这个路径下:D:\ProgramData\Anaconda3\envs\tfenv\Lib\site-packages

然后在prompt终端进入到这个路径下,用pip指令安装,版本不对的话会报下面的错:

(tfenv) D:\ProgramData\Anaconda3\envs\tfenv\Lib\site-packages>pip install face_recognition-1.0.0-py2.py3-none-any.whl
Processing d:\programdata\anaconda3\envs\tfenv\lib\site-packages\face_recognition-1.0.0-py2.py3-none-any.whl
Requirement already satisfied: scipy>=0.17.0 in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==1.0.0)
Requirement already satisfied: Click>=6.0 in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==1.0.0)
Requirement already satisfied: face-recognition-models>=0.2.0 in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==1.0.0)
Requirement already satisfied: numpy in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==1.0.0)
Requirement already satisfied: Pillow in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==1.0.0)
Collecting dlib>=19.5 (from face-recognition==1.0.0)
  Downloading http://mirrors.aliyun.com/pypi/packages/f1/40/e407366816646bb452578997e6ca2140f004eec8f611e8512ee429ded2be/dlib-19.20.0.tar.gz (3.2MB)
    100% |████████████████████████████████| 3.2MB 6.3MB/s
Requirement already satisfied: olefile in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from Pillow->face-recognition==1.0.0)
Building wheels for collected packages: dlib
  Running setup.py bdist_wheel for dlib ... error

报错信息Collecting dlib>=19.5 (from face-recognition==1.0.0),而我的dlib版本是19.4的。

重新下载一个版本用这个指令安装:pip install face_recognition-0.1.14-py2.py3-none-any.whl

(tfenv) D:\ProgramData\Anaconda3\envs\tfenv\Lib\site-packages>pip install face_recognition-0.1.14-py2.py3-none-any.whl
Processing d:\programdata\anaconda3\envs\tfenv\lib\site-packages\face_recognition-0.1.14-py2.py3-none-any.whl
Requirement already satisfied: face-recognition-models in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==0.1.14)
Requirement already satisfied: numpy in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==0.1.14)
Requirement already satisfied: scipy>=0.17.0 in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==0.1.14)
Requirement already satisfied: Pillow in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==0.1.14)
Requirement already satisfied: Click>=6.0 in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==0.1.14)
Requirement already satisfied: dlib>=19.3.0 in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from face-recognition==0.1.14)
Requirement already satisfied: olefile in d:\programdata\anaconda3\envs\tfenv\lib\site-packages (from Pillow->face-recognition==0.1.14)
Installing collected packages: face-recognition
Successfully installed face-recognition-0.1.14

在spyder中import face_recognition,成功!

你可能感兴趣的:(环境搭建)