Getting Import error while importing face_recognition in PyCharm - python

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)
Install cmake: pip install cmake
After cmake is successfully installed
Optional: Install git if you don't have git
git clone https://github.com/davisking/dlib.git
build the main dlib library
cd dlib
mkdir build; cd build; cmake ..; cmake --build .
Build and install python essentials
cd ..
python3 setup.py install
After all this run these to verify
python3
>> import dlib
Now install face_recognition
pip3 install face_recognition
Takes some time but that is okay! I hope it worked for you
Refer these materials:
face-recognition original repo: https://github.com/ageitgey/face_recognition#installing-on-mac-or-linux
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....

Related

pip3 install face_recognition error [Windows]

I am trying to follow this tutorial https://towardsdatascience.com/a-beginners-guide-to-building-your-own-face-recognition-system-to-creep-out-your-friends-df3f4c471d55. I was able to run the pip3 install cmake but not pip3 install face_recognition or pip3 install dlib. When executing those commands, i receive the following:
error message
I already have Visual Studio Code 2020 with Python, C/C++ and Cmake extensions installed.
My python version is 3.8.5.
I got it to work! Thanks for helping gulbaz khan. But I still don’t know what bug it is but this is what I did to make it work:
I had to install dlib manually into my desktop. There are a handful of repositories in github to find this. From my command prompt, i accessed the directory which containts the dlib .whl file and ran that. Afterwards, i pip install face_recognition and everything has been installed!

Installing a repo not in PyPI

This is my first time trying to install a repo not in PyPI. I'm not sure if I'm having a general issue or a specific issue with the package.
Repo:
https://github.com/jeslago/epftoolbox
Instructions are:
git clone https://github.com/jeslago/epftoolbox.git
cd epftoolbox
Then, simply install the library using pip:
pip install .
I've tried several approaches.
I tried adding the repo in Pycharm, as "https://github.com/jeslago/epftoolbox.git/" in the settings.
I tried using pip install from a local version of the repo
python -m pip install C:\Users\user\epftoolbox\
I tried installing in anaconda
git clone https://github.com/jeslago/epftoolbox.git
cd epftoolbox
pip install .
I get this error
Successfully built epftoolbox termcolor
ERROR: tensorflow 2.3.0 has requirement scipy==1.4.1, but you'll have scipy 1.5.2 which is incompatible.
But it finishes with "Successfully installed epftoolbox-1.0"
The issue is that I can do "import epftoolbox"
Fine. But if I try and run a script with "from epftoolbox.data import read_data"
I get the error
ModuleNotFoundError: No module named 'epftoolbox.data'
So I take it that the package didn't actually install?
I'm not sure what to try next?
I've python 3.8.5 installed 64 bit.
I've get the same issue in pycharm and idle.
Probably you need to install specific version of scipy to work with this library, try to uninstall current version and then install the correct version with this commands:
python -m uninstall scipy
python -m install -Iv scipy==1.4.1

Why Python does not see newly built CV2 package in Windows 10 PC?

I am following step by step instructions from "How to Build and Install OpenCV from Source". I was able to get everything installed and compiled properly in Visual studio.
When I built "INSTALL" project, it was completed as follows with no issues.
I added the path "C:\object_detector\opencv-4.3.0\build\install\x64\vc16\bin" to Environment settings.
CMAKE Python path is the same version I am running when testing the CV2. When I issue "import cv2" at Python prompt, I get error : "No module name cv2"
When I run opencv_version.exe in the new build folder shows exact OpenCV version I built. This suggests the built was successful.
Why Python does not see my build ?
You need to install the dependencies. Using pip:
pip install -r requirements.txt.
If you had it, you need to upgrade
python -m pip install --upgrade pip
If you already installed OpenCV, afterward you have got to install
pip install opencv-contrib-python
You should check those things.
The issues was that during make, it did not update Include folder in system path. Once added, it was fine.

Installing fix_yahoo_finance without pip in Anaconda

I am learning Python and use Anaconda navigator 1.8.7 and Spyder 3.3.0 (Python 3.6.6 32 bits, QT 5.9.4, PyQt5 5.9.2 on Windows). I would like to install a package called 'fix_yahoo_finance' without using pip since I have read that pip creates problems for Anaconda users.
I know that this is the line of code used when using pip:
pip install fix_yahoo_finance --upgrade --no-cache-dir
When I tried using
conda install fix_yahoo_finance
and I get a 'Solving environment: failed'
How do I get this package without using pip? Is there an alternative way that I could run this package in Anaconda like placing it in the pkgs folder?? I am absolutely confused and would really appreciate your help on this.
Thanks a lot in advance.
You can actually install it from other way around as well, clone this repo into your local system.
git clone https://github.com/ranaroussi/fix-yahoo-finance.git
Then go to the directory fix-yahoo-finance or any dir that you have cloned the repo. Then run sudo python3 setup.py install
This way too you can install the package without using pip, but make sure your python is pointing to the Anaconda's python, otherwise the only way to install it would be to copy the package folder from the site-pacakges and paste inside the Conda's package folder. Also you can look around your conda install error, https://github.com/conda/conda/issues/6390

Error of Installing dlib in anaconda

I'm trying to install Dlib in anaconda python with this line:
conda install -c menpo dlib
and I'm getting error like this:
UnsatisfiableError: The following specifications were found to be in conflict:
- dlib
- xlwt
Use "conda info <package>" to see the dependencies for each package.
How can I solve this problem?
Path of core-meta: C/users/{xxx}/anaconda3/core-meta
Delete core-meta then run the following commands:
Conda update --all
Conda install dlib
These commands require an internet connection so keep wifi on during the command running process.
Here xxx is the username on your computer.
If you do not need the xlwt-package for your project, just create a new conda environment and install the dlip package locally in that environment.
you can also try following:
brew install cmake
brew install boost
then create a virtual environment using conda command
conda create -n dlib python=3.6 anaconda
Activate the environment
source activate dlib
run the following command
conda install pip
and finally install dlib using below command
pip install dlib
This worked for me.
For anaconda or miniconda3, please see the following installation procedures. It will comply with Python 3.7 in this way.
1.Install cmake with git
$ sudo apt-get install git cmake
2. Enter into the the directory
Please change user to your own username
$ cd /home/user/dlib
3. Compile dlib
$ python setup.py install
If meeting with the issue that you could not put the import statements of setuptools behind the import statement of distutils, please change the placement oder in setup.py in the directory of dlib.
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from distutils import log
from distutils.version import LooseVersion
4. Run the dlib unit test suite in the current working directory
Please note there is a sub-directory of dlib inlcuded in the directory of dlib.
$ cd dlib/test
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build . --config Release
$./dtest --runall
Cheers.
on mac system :
you have to do it via brew
brew install cmake
brew install boost
brew install boost-python --with-python3
After installing above packages if you need you can create your environment and proceed with dlib installation or you can simply run next step.
The dlib library doesn’t have any real Python prerequisites, but if you plan on using dlib for any type of computer vision or image processing, These are few libraries which you can install for dlib :
* NumPy
* SciPy
* scikit-image
pip install numpy
5 pip install Scipy
pip install scikit-image
pip install dlib
you can check for more details on this link:
https://www.pyimagesearch.com/2017/03/27/how-to-install-dlib/
You have to try by putting just:
conda install dlib

Categories

Resources