Forums

Face_recognition installation in Pythonanywhere gives error.

I tried to install dlib using shell and it was installed but when I tried to install face_recognition, it gives this error. Any solutions, I badly need it for my project.

  Failed building wheel for dlib
  Running setup.py clean for dlib
  Running setup.py bdist_wheel for face-recognition-models ... done
  Stored in directory: /home/InsureVite/.cache/pip/wheels/d2/99/18/59c6c8f01e39810415c0e63f5bede7d83dfb0ffc039865465f
Successfully built face-recognition-models
Failed to build dlib
Installing collected packages: dlib, face-recognition-models, face-recognition
  Running setup.py install for dlib ... error
    Complete output from command /usr/local/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-rzulo_6m/dlib/setup.py';f=geta
ttr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip
-of5teab5-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    running install
    running build
    running build_py
    package init file 'dlib/__init__.py' not found (or not a regular file)
    running build_ext
    error: [Errno 38] Function not implemented

    ----------------------------------------
Command "/usr/local/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-rzulo_6m/dlib/setup.py';f=getattr(tokenize, 'open', op
en)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-of5teab5-record/install
-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-rzulo_6m/dlib/

[edited by admin: formatting]

are you sure you installed dlib correctly? how did you install it?

I ran a shell file having this script. When I tested it after installation. Python3.6-> Import dlib. It didn't give me any error, so I assume its correct.

 #!/bin/bash

echo "Installing Dependenices"
sudo apt-get -y install build-essential cmake libx11-dev git

mkdir ~/Dlib
cp compile_dlib.sh ~/Dlib/
cd ~/Dlib
echo "Downloading Dlib"
git clone https://github.com/davisking/dlib.git

echo "Installing Dlib"
cd dlib 
mkdir build
cd build 
cmake .. -DUSE_AVX_INSTRUCTIONS=ON
cmake --build . --config Release
make 
sudo make install
sudo ldconfig

echo "Compiling the Dlib Unit Test"
cd ~/Dlib/dlib/dlib/test
mkdir build
cd build
cmake ..
cmake --build . --config Release

are you sure your dlib installation was successful? I'm thinking it error-ed silently.

I think dlib is not very compatible with python3. We actually already have dlib installed for you on python2.

I don't think so, it's pre-installed. Any Guidance for installation?

 Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named dlib
>>>

Tried installation via pip but no success.

    17:31 ~/.virtualenvs/myvirtualenv $ pip2 install --user dlib
Collecting dlib                                                                                                                       
  Downloading https://files.pythonhosted.org/packages/97/08/0d2b53b3845d562d01108e482ae45596a0d13bf58c63172df954ff0b53ef/dlib-19.14.0.
tar.gz (3.3MB)                                                                                                                        
    100% |████████████████████████████████| 3.3MB 224kB/s 
Building wheels for collected packages: dlib                                                                                          
  Running setup.py bdist_wheel for dlib ... error                                                                                     
  Complete output from command /usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-McTHWU/dlib/setup.
py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmppO
NPEcpip-wheel- --python-tag cp27:                                                                                                     
  running bdist_wheel                                                                                                                 
  running build                                                                                                                       
  running build_py                                                                                                                    
  package init file 'dlib/__init__.py' not found (or not a regular file)                                                              
  running build_ext                                                                                                                   
  error: [Errno 38] Function not implemented

  ----------------------------------------                                                                                            
  Failed building wheel for dlib                                                                                                      
  Running setup.py clean for dlib                                                                                                     
Failed to build dlib                                                                                                                  
Installing collected packages: dlib                                                                                                   
  Running setup.py install for dlib ... error
    Complete output from command /usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-McTHWU/dlib/setu
p.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/p
ip-zl_zce-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    running install
    running build
    running build_py
    package init file 'dlib/__init__.py' not found (or not a regular file)
    running build_ext
    error: [Errno 38] Function not implemented

    ----------------------------------------
Command "/usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-McTHWU/dlib/setup.py';exec(compile(getat
tr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zl_zce-record/install
-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-McTHWU/dlib/
17:32 ~/.virtualenvs/myvirtualenv $

Sorry for the confusion, I think Conrad was mistaken when he said that dlib was pre-installed -- it looks like he'd just previously installed it into his own account.

As far as I can see, there's a problem with the current version of dlib that stops it from working on PythonAnywhere. However, I was successfully able to install a slightly earlier version, 19.3. The command for that is, if you're not in a virtualenv:

pip2.7 install --user dlib==19.3.1

...or, alternatively, if you are in a virtualenv:

pip install dlib==19.3.1

ThankYou Guys.

Hi again! I installed dlib 19.3.1 and then again tried installing face_recognition but it gave this error. Still stuck at the same point. Any Help?

20:33 ~/.virtualenvs/myvirtualenv $ pip2 install --user face_recognition
    Collecting face_recognition
      Using cached https://files.pythonhosted.org/packages/28/10/f153bbbc218fc169768aa1c02f2e9178e9241e4af8da56289bdca2c0c217/face_recognition-1.2.2-py2.py3-none-any.whl
    Requirement already satisfied (use --upgrade to upgrade): Click>=6.0 in /usr/local/lib/python2.7/dist-packages (from face_recognition)
    Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python2.7/dist-packages (from face_recognition)
    Collecting dlib>=19.7 (from face_recognition)
      Using cached https://files.pythonhosted.org/packages/97/08/0d2b53b3845d562d01108e482ae45596a0d13bf58c63172df954ff0b53ef/dlib-19.14.0.tar.gz
    Requirement already satisfied (use --upgrade to upgrade): Pillow in /usr/local/lib/python2.7/dist-packages (from face_recognition)
    Collecting face-recognition-models>=0.3.0 (from face_recognition)
    Building wheels for collected packages: dlib
      Running setup.py bdist_wheel for dlib ... error
      Complete output from command /usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-NgJdMR/dlib/setup.
    py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpu8
    IbIHpip-wheel- --python-tag cp27:
      running bdist_wheel
      running build
      running build_py
      package init file 'dlib/__init__.py' not found (or not a regular file)
      running build_ext
      error: [Errno 38] Function not implemented

      ----------------------------------------
      Failed building wheel for dlib
      Running setup.py clean for dlib
    Failed to build dlib
    Installing collected packages: dlib, face-recognition-models, face-recognition
      Found existing installation: dlib 19.3.1
        Uninstalling dlib-19.3.1:
          Successfully uninstalled dlib-19.3.1
      Running setup.py install for dlib ... error
        Complete output from command /usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-NgJdMR/dlib/setu
    p.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/p
    ip-jwlwui-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
        running install
        running build
        running build_py
        package init file 'dlib/__init__.py' not found (or not a regular file)
        running build_ext
        error: [Errno 38] Function not implemented

        ----------------------------------------
      Rolling back uninstall of dlib
    Command "/usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-NgJdMR/dlib/setup.py';exec(compile(getat
    tr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-jwlwui-record/install
    -record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-NgJdMR/dlib/

Umm! I figured it out. The latest version of face_recognition requires latest version of dlib, so it uninstalls the previous one and tries to install the latest one which doesn't work here. So I installed a previous version of face_recognition==0.2.2 and its working with dlib==19.3.1 Thank You.

Excellent! Glad you worked it out :-)