Dlib not working

I cannot get dlib working with hass.io

2017-09-29 12:23:46 ERROR (SyncWorker_16) [homeassistant.util.package] Unable to install package face_recognition==1.0.0: Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aw5k07du/dlib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-qfadbqs3-record/install-record.txt --single-version-externally-managed --prefix  --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-aw5k07du/dlib/
2017-09-29 12:23:46 ERROR (MainThread) [homeassistant.setup] Not initializing image_processing.dlib_face_detect because could not install dependency face_recognition==1.0.0
2017-09-29 12:23:46 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform image_processing.dlib_face_detect: Could not install all requirements.

Does anyone know how to fix this?

(Just ran into this myself) Dlib needs some libraries compiled for it to load and the hass.io image doesn’t have them pre-loaded. I was able to get it installed in my instance by attaching to the homeassistant container and adding the packages as such…

# apk update
# apk add build-base gcc abuild binutils cmake boost-python boost-dev python3-dev libressl-dev libffi-dev
# /usr/bin/pip3 install face_recognition==1.0.0

To be totally honest, I don’t know exactly which library was needed to make it work, I just started adding them until face_recognition would install :slight_smile:

I should add that it took a good 5 minutes to compile on my 6-core 3.5GHz docker host, so be patient if it looks hung.

Do you know if this is still the case? I’m trying to use dlib on hassio

Edit: Im getting the below error

2018-01-23 12:00:08 ERROR (SyncWorker_19) [homeassistant.util.package] Unable to install package face_recognition==1.0.0: Exception:

yep same here 0.64 any solution?

I’m having the same issue

apologies, forgot to report back. I raised a PR for the documentation. Needs cmake it seems (well it did on my ubuntu build. Seemingly AIO and docker does not)

see at the bottom

Thanks, but how to install cmake in Hassio? I can do it inside a container, but after Homeassistant restart changes will be lost.

same problem here,

Well, I found solution.
Home assistant previously (afaik <0.50 version) stored dependences in /deps folder under config folder. So, we are able to place missing packages here.
What I did:

  1. ssh to Hassio (not Home Assistant container, but Resin instance)
  2. docker ps to get homeassistant container id
  3. docker exec -it <ID_here> ash to get to the container shell
  4. pip3 install face_recognition to install dependences
  5. cp -r /usr/lib/python3.6/site-packages/face-recognition /config/deps/lib/python3.6/site-packages/ config folder is persistant, so it would survive container restart
  6. ctrl+p ctrl+q to detach from container
  7. ssh to Home Assistant container as usual and restart it

Thats it, dlib component now initializes properly.
But I have another error

 RuntimeError: Error deserializing object of type int64
   while deserializing a floating point number.
   while deserializing a dlib::matrix
   while deserializing object of type std::vector
   while deserializing object of type std::vector
   while deserializing object of type std::vector

but I think it caused by something else.

Can’t get this to work anymore home assistant moved on to python3.7 and the package copied to either /config/deps/lib/python3.6/site-packages/ or /config/deps/lib/python3.7/site-packages/ is not picked up anymore. Any ideas?

Solved it by injecting a custom initialization script to the container:

  homeassistant:
    image: homeassistant/home-assistant:stable
    [...]
    volumes:
    - /data/home-assistant/cont-init.d/custom-packages.sh:/etc/cont-init.d/custom-packages.sh

/data/home-assistant/cont-init.d/custom-packages.sh with the following content:

#!/bin/sh
apk add cmake
apk add gcc
apk add g++
apk add make