Error in Installing the face-recognition facing errors

Building wheels for collected packages: dlib, validators
  Building wheel for dlib (setup.py): started
  Building wheel for dlib (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      
      ERROR: CMake must be installed to build dlib
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for dlib
  Running setup.py clean for dlib
  Building wheel for validators (setup.py): started
  Building wheel for validators (setup.py): finished with status 'done'
  Created wheel for validators: filename=validators-0.20.0-py3-none-any.whl size=19579 sha256=f923fa28ec5b7647e86467fe35861f4389bb3d7ea8740dfe912f502ecded35ad
  Stored in directory: /tmp/pip-ephem-wheel-cache-eapue6_u/wheels/2d/f0/a8/1094fca7a7e5d0d12ff56e0c64675d72aa5cc81a5fc200e849
Successfully built validators
Failed to build dlib
Installing collected packages: SMTPEmail, pytz, dlib, commonmark, cmake, zipp, watchdog, urllib3, tzdata, typing-extensions, tornado, toolz, toml, smmap, six, setuptools, semver, pyrsistent, pyparsing, pympler, pygments, protobuf, pillow, numpy, MarkupSafe, idna, entrypoints, decorator, click, charset-normalizer, certifi, cachetools, blinker, attrs, zope.interface, validators, rich, requests, pytz-deprecation-shim, python-dateutil, pyarrow, packaging, opencv-python, jsonschema, jinja2, importlib-metadata, gitdb, tzlocal, pydeck, pandas, gitpython, DateTime, altair, streamlit
  Running setup.py install for dlib: started
  Running setup.py install for dlib: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Running setup.py install for dlib did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      running install
      /home/appuser/venv/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      running build_ext
      
      ERROR: CMake must be installed to build dlib
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> dlib

Hi @Sailatish,

Thanks for posting!

Can you share a little more info to help us troubleshoot? What are you doing that’s resulting in this error?

Caroline :balloon:

I would like to deploy my python code which includes the face-recognition module and while deploying there was an error that the dlib module which was required for face-recognition was unable to install can you help me with that please

Thanks for clarifying! Can you share a link to your GitHub repo or the requirements file?

I’m not sure how best to phrase this, but as I understand it, it is impossible to install the face-recognition library on Streamlit Community Cloud.

Why? The installation of face-recognition requires dlib to be compiled. When dlib is being compiled, the compiler runs out of RAM and gets OOM-killed. The default 1GB of RAM is insufficient to build the dlib dependency for the face_recognition Python package.

I’ve been unsuccessful in getting face_recognition installed on Cloud via all methods Pipenv, requirements.txt, environment.yml, and pyproject.toml. Happy to proven wrong though :sweat_smile:

You can get the requirements’ text file please go through this

That was really bad! :upside_down_face:

Could you elaborate? I think my rationale for why it fails to install is technically sound (if the traceback and installation logs are to be believed). Sorry I don’t have a workaround in this instance…

Any updates on this subject?
So far I have tried everything I know to deploy my app with face_recognition and nothing works! besides local…
What can I do to make it work? I specially want to use my smartphone camera, and locally (because its http, not https) it’s ironically harder to use the phone’s camera… ‘for security reasons’ :thinking:

Any workaround to deploy de app beyound localhost?

Unfortunately, the answer is the same:

The face-recognition library during installation exceeds the app’s resource limits on Community Cloud. The only solution is to deploy your app on another cloud provider that provides >= 3 GB RAM per app.

I’ll try to find out places to deploy with more than 3Gb.

One question: is there a way to upload a compiled version of dlib? That’s how I installed dlib in a Windows PC (I didn’t want to install Visual Studio for that), and it works just fine… Maybe a compiled version of dlib for Ubuntu could work just fine

There is a dlib source package in Ubuntu, but none of the binary packages build from it seems to include the python API. There is no python3-dlib package either. I don’t know why that is the case or whether it might be of any help.
https://packages.ubuntu.com/source/jammy/dlib

Hey there,
just make a fork of face_recognition and change dlib requiment in setup.py to → dlib-bin :exclamation:

Then go ahead and tell streamlit to use your fork in your requirements.txt like this

face_recognition @ git+https://github.com/thetoby9944/face_recognition

This will make sure face_recognition is using the precompiled dlib library instead of trying to compile itself.

That way the face_recognition is working for me on streamlit cloud. :+1: Hope i could help

5 Likes

This link will solve all your problem👇

This worked for me - awesome fix!

signed up just so I could thank you :face_holding_back_tears:, this saved me!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.