繁体   English   中英

在 PyCharm 中导入 face_recognition 时出现导入错误

[英]Getting Import error while importing face_recognition in PyCharm

我是 PyCharm 的新手,正在尝试一些人脸识别的东西。 我的工作需要一个 face_recogniton 库,它是使用以下命令安装的(我使用 Ubuntu 18.04 作为我的操作系统):

pip install face_recognition

我可以在 python 解释器中导入它,但它在 PyCharm 中抛出导入错误

ImportError: No module named 'face_recognition'

感谢您为帮助我所做的努力。

为Ubuntu 18.04安装人脸识别模块:(尝试其他操作系统,我用这个用于18.04)

  1. 安装cmake: pip install cmake cmake安装成功后

  2. 可选:如果没有 git,请安装 git

    git 克隆https://github.com/davisking/dlib.git

  3. 构建主 dlib 库

    cd dlib mkdir 构建; 光盘构建; 制作..; cmake——构建。

  4. 构建和安装 python 必需品

    cd .. python3 setup.py 安装

毕竟这运行这些来验证

python3 
>> import dlib
  1. 现在安装face_recognition

    pip3 安装人脸识别

需要一些时间,但没关系! 我希望它对你有用

参考这些材料:

  1. 人脸识别原始仓库: https ://github.com/ageitgey/face_recognition#installing-on-mac-or-linux
  2. dlib: https://gist.github.com/ageitgey/629d75c1baac34dfa5ca2a1928a7aeaf

阅读github 上的 face_recognition 安装指南,确保已安装 dlib,然后使用以下命令安装 face_recognition:

pip3 安装人脸识别

此外,检查 PyCharm 是否正在使用您安装 face_recognition 的环境。 也许 PyCharm 创建了它自己的虚拟环境,而您在没有 face_recognition 的情况下使用它。

有关如何在 PyCharm env 中安装模块的更多信息,请检查此答案,除了 pygame 检查是否列出了 face_recognition。 如果没有,请安装它。

看起来您可能已经安装了多个版本的 Python。 您似乎已经为 python 版本 2 安装了 face_recognition,而您正试图从 Python 版本 3 访问该模块。您应该考虑使用虚拟环境并相应地设置 Python Interpreter。

按照https://www.jetbrains.com/help/idea/configuring-local-python-interpreters.html了解如何配置解释器。

cmake.org下载此文件cmake-3.17.0-rc3-win64-x64.msi并安装它(默认情况下它将安装在C:\Program Files\CMake\bin中)。

安装后复制此路径并编辑环境变量 -> 路径 -> 粘贴该路径 -> 单击确定。 打开cmd,现在使用pip install face_recognition

我希望它能奏效……

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM