[英]Getting Import error while importing face_recognition in PyCharm
I am new to PyCharm and trying some face recognition stuff.我是 PyCharm 的新手,正在尝试一些人脸识别的东西。 I need a face_recogniton library for my work which is installed using the following command (I'm using Ubuntu 18.04 as my OS):
我的工作需要一个 face_recogniton 库,它是使用以下命令安装的(我使用 Ubuntu 18.04 作为我的操作系统):
pip install face_recognition
I am able to import it in python interpreter but it throws import error in PyCharm我可以在 python 解释器中导入它,但它在 PyCharm 中抛出导入错误
ImportError: No module named 'face_recognition'
. ImportError: No module named 'face_recognition'
。
Thanks for your effort in helping me.感谢您为帮助我所做的努力。
For installing face-recognition module for Ubuntu 18.04: (Try for other OS, I used this for 18.04)为Ubuntu 18.04安装人脸识别模块:(尝试其他操作系统,我用这个用于18.04)
Install cmake: pip install cmake
After cmake is successfully installed安装cmake:
pip install cmake
cmake安装成功后
Optional: Install git if you don't have git可选:如果没有 git,请安装 git
git clone https://github.com/davisking/dlib.git git 克隆https://github.com/davisking/dlib.git
build the main dlib library构建主 dlib 库
cd dlib mkdir build; cd dlib mkdir 构建; cd build;
光盘构建; cmake..;
制作..; cmake --build.
cmake——构建。
Build and install python essentials构建和安装 python 必需品
cd.. python3 setup.py install cd .. python3 setup.py 安装
After all this run these to verify毕竟这运行这些来验证
python3
>> import dlib
Now install face_recognition现在安装face_recognition
pip3 install face_recognition pip3 安装人脸识别
Takes some time but that is okay!需要一些时间,但没关系! I hope it worked for you
我希望它对你有用
Refer these materials:参考这些材料:
Reading face_recognition installation guide on github , make sure you have dlib installed and then install face_recognition with:阅读github 上的 face_recognition 安装指南,确保已安装 dlib,然后使用以下命令安装 face_recognition:
pip3 install face_recognition
pip3 安装人脸识别
Also, check if PyCharm is using environment where you installed face_recognition.此外,检查 PyCharm 是否正在使用您安装 face_recognition 的环境。 Maybe PyCharm created it's own virtual env and you are using it without face_recognition.
也许 PyCharm 创建了它自己的虚拟环境,而您在没有 face_recognition 的情况下使用它。
For more info about how to install module in PyCharm env, please check this answer , just except pygame check if face_recognition is listed.有关如何在 PyCharm env 中安装模块的更多信息,请检查此答案,除了 pygame 检查是否列出了 face_recognition。 If not, install it.
如果没有,请安装它。
Looks like you have installed maybe multiple versions of Python.看起来您可能已经安装了多个版本的 Python。 You seem to have installed face_recognition for python version 2, whereas you are trying to access the module from Python version 3. You should consider using virtual environments and set up Python Interpreter accordingly.
您似乎已经为 python 版本 2 安装了 face_recognition,而您正试图从 Python 版本 3 访问该模块。您应该考虑使用虚拟环境并相应地设置 Python Interpreter。
Follow https://www.jetbrains.com/help/idea/configuring-local-python-interpreters.html on how to configure the interpreter.按照https://www.jetbrains.com/help/idea/configuring-local-python-interpreters.html了解如何配置解释器。
Download this file cmake-3.17.0-rc3-win64-x64.msi
from cmake.org and install it (By default it will be installed in C:\Program Files\CMake\bin
).从cmake.org下载此文件
cmake-3.17.0-rc3-win64-x64.msi
并安装它(默认情况下它将安装在C:\Program Files\CMake\bin
中)。
After the installation copy this path and edit environment variable -> path -> paste that path -> click ok.安装后复制此路径并编辑环境变量 -> 路径 -> 粘贴该路径 -> 单击确定。 Open the cmd and now use
pip install face_recognition
打开cmd,现在使用
pip install face_recognition
i hope it should work....我希望它能奏效……
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.