简体   繁体   中英

Getting Import error while importing face_recognition in PyCharm

I am new to PyCharm and trying some face recognition stuff. 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):

pip install face_recognition

I am able to import it in python interpreter but it throws import error in PyCharm

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)

  1. Install cmake: pip install cmake After cmake is successfully installed

  2. Optional: Install git if you don't have git

    git clone https://github.com/davisking/dlib.git

  3. build the main dlib library

    cd dlib mkdir build; cd build; cmake..; cmake --build.

  4. Build and install python essentials

    cd.. python3 setup.py install

After all this run these to verify

python3 
>> import dlib
  1. Now install face_recognition

    pip3 install face_recognition

Takes some time but that is okay! I hope it worked for you

Refer these materials:

  1. face-recognition original repo: https://github.com/ageitgey/face_recognition#installing-on-mac-or-linux
  2. dlib: https://gist.github.com/ageitgey/629d75c1baac34dfa5ca2a1928a7aeaf

Reading face_recognition installation guide on github , make sure you have dlib installed and then install face_recognition with:

pip3 install face_recognition

Also, check if PyCharm is using environment where you installed face_recognition. Maybe PyCharm created it's own virtual env and you are using it without 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. If not, install it.

Looks like you have installed maybe multiple versions of 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.

Follow https://www.jetbrains.com/help/idea/configuring-local-python-interpreters.html on how to configure the interpreter.

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 ).

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

i hope it should work....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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