安装face_recognition库出错

问题描述 投票:0回答:3

安装face_recognition库时出现下面提到的cmake错误如何解决?

Collecting face_recognition
  Using cached face_recognition-1.2.1-py2.py3-none-any.whl
Requirement already satisfied: face-recognition-models>=0.3.0 in ./anaconda/lib/python3.6/site-packages (from face_recognition)
Requirement already satisfied: Pillow in ./anaconda/lib/python3.6/site-packages (from face_recognition)
Requirement already satisfied: Click>=6.0 in ./anaconda/lib/python3.6/site-packages (from face_recognition)
Requirement already satisfied: scipy>=0.17.0 in ./anaconda/lib/python3.6/site-packages (from face_recognition)
Collecting dlib>=19.7 (from face_recognition)
  Using cached dlib-19.10.0.tar.gz
Requirement already satisfied: numpy in ./anaconda/lib/python3.6/site-packages (from face_recognition)
Requirement already satisfied: olefile in ./anaconda/lib/python3.6/site-packages (from Pillow->face_recognition)
Building wheels for collected packages: dlib
  Running setup.py bdist_wheel for dlib ... error
  Complete output from command /Users/muralidharan/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/dlib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/tmpw6lzrrukpip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  package init file 'dlib/__init__.py' not found (or not a regular file)
  running build_ext
  Invoking CMake setup: 'cmake /private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/dlib/build/lib.macosx-10.7-x86_64-3.6 -DPYTHON_EXECUTABLE=/Users/muralidharan/anaconda/bin/python -DCMAKE_BUILD_TYPE=Release'
  error: [Errno 2] No such file or directory: 'cmake'

  ----------------------------------------
  Failed building wheel for dlib
  Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib, face-recognition
  Running setup.py install for dlib ... error
    Complete output from command /Users/muralidharan/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/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 /var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-qhc3clwr-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    package init file 'dlib/__init__.py' not found (or not a regular file)
    running build_ext
    Invoking CMake setup: 'cmake /private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/dlib/build/lib.macosx-10.7-x86_64-3.6 -DPYTHON_EXECUTABLE=/Users/muralidharan/anaconda/bin/python -DCMAKE_BUILD_TYPE=Release'
    error: [Errno 2] No such file or directory: 'cmake'

    ----------------------------------------
Command "/Users/muralidharan/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/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 /var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-qhc3clwr-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/dlib/ 
python-3.x cmake anaconda
3个回答
1
投票

对于我来说,我在ubuntu16 python2.7中安装face_recognition,我编写了一个shell来安装它。

#!/bin/bash
# This shell script install face_recognition in ubuntu16 python2.7

apt-get -y install git
apt-get -y install cmake
# install dlib without cuda
git clone https://github.com/davisking/dlib.git
cd dlib
mkdir build; cd build; cmake .. ; cmake --build .

# install dlib python interface
cd -
apt-get -y install python-setuptools

apt-get -y install python-dev
python setup.py install

# install face_recognition
apt-get -y install python-pip
pip install face_recognition

0
投票
error: [Errno 2] No such file or directory: 'cmake'

我最近遇到了同样的问题,我下载了CMAKE解决了它。

这是每个操作系统的下载链接


0
投票

当你安装face_recognition库时,它会抛出错误-

Failed building wheel for dlib
 Running setup.py clean for dlib
 Failed to build dlib
 Installing collected packages: dlib, face-recognition
 Running setup.py install for dlib ... error
 Complete output from command /Users/muralidharan/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/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 /var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-qhc3clwr-record/install-record.tx


----------


t --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    package init file 'dlib/__init__.py' not found (or not a regular file)
    running build_ext
    Invoking CMake setup: 'cmake /private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/var/folders/xz/rcv9f_6x41gcvhrqzsd6mrxw0000gn/T/pip-build-5zqyoigf/dlib/build/lib.macosx-10.7-x86_64-3.6 -DPYTHON_EXECUTABLE=/Users/muralidharan/anaconda/bin/python -DCMAKE_BUILD_TYPE=Release'
    error: [Errno 2] No such file or directory: 'cmake'

现在,如果您选择 dlib,它将显示相同的错误“找不到 cmake 模块......无法为 dlib 构建轮子”

现在安装了 cmake 库也没有任何好处

经过成功尝试和测试的方法-

  1. 为了安全起见,请访问 Visual Studio 并下载社区版本 启动安装过程;当您处于开发人员工具选择步骤时......请务必选择 使用 C++ 进行桌面开发 Visual Studio Configure 配置完成后,选择下载时安装

再次强调,上述过程只是为了安全起见,因为 dlib 和此类库需要 C++ 开发工具

2.当前版本的python不兼容dlib和face_recognition库。所以我们要降级我们的 python 版本以便能够进一步进行。 前往Python官方网站并下载2021年5月3日的Python版本3.8.10 在 python 3.8.10 的安装过程中,请务必选择将 python.exe 添加到路径

*现在你的桌面上又多了一个Python版本* 要检查当前有多少个可用......在 cmd 上运行此命令:

py -0

要选择任何特定版本,请使用:

py -*version?*
这将为您带来所需 python 版本的解释器,但您无法在此处安装任何包!

在终端中运行 python --version 它返回 python 的当前版本以及您的系统首先遇到的版本

但是,我们要使用python版本3.8.10 因此您不必卸载当前版本,从而避免将来出现问题;相反,请转到编辑系统环境变量 转到用户或系统的 PATH > 搜索所需的 python 版本,即 3.8.10 PATH 并将其移动到顶部,从而确保系统可以首先获取此版本

注意:如果稍后出现有关版本的任何问题,为了避免任何混淆,您应该删除不需要的 python 版本的 PATH,稍后当您完成 dlib 和 Face_recognition 的安装后,您基本上可以将这些 PATH 添加回系统环境变量中,我鉴于您按照指示执行了每一步,请确保它不会导致任何其他错误。

现在回来了;只是为了确保关闭终端,重新打开它并运行

python --version
:它应该返回所需的版本,即 3.8.10

现在在终端中将目录更改为您想要的位置; 在此目录中,您有两个选项可以在虚拟环境中工作 或相同环境

使用虚拟环境,你只需要先安装 virtualenv 包

pip install virtualenv

创建您自己的虚拟环境

python -m venv myenv

通过更改目录进入该虚拟环境,一旦进入,就必须运行

./Scripts/activate 

激活您创建的虚拟环境。

现在只需安装库即可:

pip install face_recognition

需要一些时间,但它会安装 现在建议将这些路径添加到系统环境变量中您当时的Python版本中,或者如果您尚未删除它,则应将其移至顶部。现在删除 3.8.10 版本应该也不成问题了。

如果对此解决方案有任何困惑,请在评论中提及 我很乐意进一步提供帮助!

© www.soinside.com 2019 - 2024. All rights reserved.