Core: QR Code Recognition

Created on 8 Feb 2019  路  16Comments  路  Source: home-assistant/core

Last working Home Assistant release (if known):
N/A

Operating environment (Hass.io/Docker/Windows/etc.):
arch | x86_64
dev | false
docker | true
hassio | true
os_name | Linux
python_version | 3.6.6
timezone | America/New_York
version | 0.87.0
virtualenv | false

Component/platform:
QR Code Recognition

Description of problem:
Fails to initialize.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

image_processing:
  - platform: qrcode
    source:
      - entity_id: camera.qr

Traceback (if applicable):

2019-02-08 12:50:47 ERROR (MainThread) [homeassistant.helpers.entity] Update for image_processing.qr_qr fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 347, in async_device_update
    await self.async_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/image_processing/__init__.py", line 138, in async_update
    await self.async_process_image(image.content)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/image_processing/qrcode.py", line 59, in process_image
    from pyzbar import pyzbar
  File "/usr/local/lib/python3.6/site-packages/pyzbar/pyzbar.py", line 7, in <module>
    from .wrapper import (
  File "/usr/local/lib/python3.6/site-packages/pyzbar/wrapper.py", line 148, in <module>
    c_uint_p,    # minor
  File "/usr/local/lib/python3.6/site-packages/pyzbar/wrapper.py", line 141, in zbar_function
    return prototype((fname, load_libzbar()))
  File "/usr/local/lib/python3.6/site-packages/pyzbar/wrapper.py", line 120, in load_libzbar
    libzbar, dependencies = zbar_library.load()
  File "/usr/local/lib/python3.6/site-packages/pyzbar/zbar_library.py", line 65, in load
    raise ImportError('Unable to find zbar shared library')
ImportError: Unable to find zbar shared library

Additional information:
I verified pyzbar is installed in docker image.
I do not know how to verify/install libzbar0.

qrcode stale

Most helpful comment

Same issue here. Is this going to be included in the official docker image ?

All 16 comments

Same issue here with venv install

I got it working by installing zbar-tools under ubuntu 18.04 After installing thse It works perfectly now

https://github.com/NaturalHistoryMuseum/pyzbar/blob/master/README.rst#installation

I think the hass.io should include the lib in the docker image and user document should update to include installation note.

I'm also seeing the same error, Running Home Assistant in Docker on my Synology 918+ with the following traceback:

Update for image_processing.qr_wallpanel fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 347, in async_device_update
    await self.async_update()
  File "/usr/src/app/homeassistant/components/image_processing/__init__.py", line 138, in async_update
    await self.async_process_image(image.content)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/image_processing/qrcode.py", line 59, in process_image
    from pyzbar import pyzbar
  File "/usr/local/lib/python3.6/site-packages/pyzbar/pyzbar.py", line 7, in <module>
    from .wrapper import (
  File "/usr/local/lib/python3.6/site-packages/pyzbar/wrapper.py", line 148, in <module>
    c_uint_p,    # minor
  File "/usr/local/lib/python3.6/site-packages/pyzbar/wrapper.py", line 141, in zbar_function
    return prototype((fname, load_libzbar()))
  File "/usr/local/lib/python3.6/site-packages/pyzbar/wrapper.py", line 120, in load_libzbar
    libzbar, dependencies = zbar_library.load()
  File "/usr/local/lib/python3.6/site-packages/pyzbar/zbar_library.py", line 65, in load
    raise ImportError('Unable to find zbar shared library')
ImportError: Unable to find zbar shared library

https://github.com/NaturalHistoryMuseum/pyzbar/blob/master/README.rst#installation

I think the hass.io should include the lib in the docker image and user document should update to include installation note.

My docker install already states that pyzbar is already installed:

Requirement already satisfied: pyzbar in /usr/local/lib/python3.6/site-packages (0.1.7)

And yet I still get the above error.

I then attempted to install just zbar and receiving the following:

 Failed building wheel for zbar                                                                                                      
  Running setup.py clean for zbar                                                                                                     
Failed to build zbar                                                                                                                  
Installing collected packages: zbar                                                                                                   
  Running setup.py install for zbar ... error                                                                                         
    Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-dhwce0xo/zbar/set
up.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-record-jafog_lz/install-record.txt --single-version-externally-managed --compile:                         
    running install                                                                                                                   
    running build                                                                                                                     
    running build_ext                                                                                                                 
    building 'zbar' extension                                                                                                         
    creating build                                                                                                                    
    creating build/temp.linux-x86_64-3.6                                                                                              
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.6m -c zbarmodule.c
 -o build/temp.linux-x86_64-3.6/zbarmodule.o                                                                                          
    In file included from zbarmodule.c:24:0:                                                                                          
    zbarmodule.h:26:18: fatal error: zbar.h: No such file or directory                                                                
     #include <zbar.h>                                                                                                                
                      ^                                                                                                               
    compilation terminated.                                                                                                           
    error: command 'gcc' failed with exit status 1                                                                                    

    ----------------------------------------                                                                                          
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-dhwce0xo/zbar/setup.py';f=getattr(tokeniz
e, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/
pip-record-jafog_lz/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-dhw
ce0xo/zbar/                                                   

I found out how a way to add zbar to the docker image. Could not find an apk for libzbar0.
Unfortunately, it has to be added after every restart. I think the hassio docker image will need to have zbar added for this to work. Unless, someone knows haw to make the install persistent.

Go into docker image
docker exec -ti homeassistant /bin/bash

Add repository

vi /etc/apk/repositories
o
https://mirror.math.princeton.edu/pub/alpinelinux/edge/testing
<esc>
:wq

Install zbar
apk --update add zbar

Same issue here. Is this going to be included in the official docker image ?

Not sure if @balloob or @pvizeli can comment on that?

I found out how a way to add zbar to the docker image. Could not find an apk for libzbar0.
Unfortunately, it has to be added after every restart. I think the hassio docker image will need to have zbar added for this to work. Unless, someone knows haw to make the install persistent.

Go into docker image
docker exec -ti homeassistant /bin/bash

Add repository

vi /etc/apk/repositories
o
https://mirror.math.princeton.edu/pub/alpinelinux/edge/testing
<esc>
:wq

Install zbar
apk --update add zbar

So, is there a way to make this persistent ?

@balloob , @pvizeli is it going to be included on the official docker image ?
Plase give us some comments.

Thanks in advance!

Install zbar
apk --update add zbar

Unfortunately this is (not yet) available on aarch64: https://pkgs.alpinelinux.org/packages?name=zbar&branch=edge

I created a request for it: https://bugs.alpinelinux.org/issues/10234

Is there going to be a fix for this ?

Update for image_processing.qr_front_door fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 375, in async_device_update
    await self.async_update()
  File "/usr/src/app/homeassistant/components/image_processing/__init__.py", line 132, in async_update
    await self.async_process_image(image.content)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/qrcode/image_processing.py", line 52, in process_image
    from pyzbar import pyzbar
  File "/usr/local/lib/python3.7/site-packages/pyzbar/pyzbar.py", line 7, in <module>
    from .wrapper import (
  File "/usr/local/lib/python3.7/site-packages/pyzbar/wrapper.py", line 148, in <module>
    c_uint_p,    # minor
  File "/usr/local/lib/python3.7/site-packages/pyzbar/wrapper.py", line 141, in zbar_function
    return prototype((fname, load_libzbar()))
  File "/usr/local/lib/python3.7/site-packages/pyzbar/wrapper.py", line 120, in load_libzbar
    libzbar, dependencies = zbar_library.load()
  File "/usr/local/lib/python3.7/site-packages/pyzbar/zbar_library.py", line 65, in load
    raise ImportError('Unable to find zbar shared library')
ImportError: Unable to find zbar shared library

I've gave up and installed hassbian instead of hassio.

I am running a home assistant in the docker on Synology Nas

Unfortunately this is (not yet) available on aarch64: https://pkgs.alpinelinux.org/packages?name=zbar&branch=edge

Seems to be fixed now.

For the hassio fix, we will probably have to wait until the package reaches main (if ever).

Unfortunately this is (not yet) available on aarch64: https://pkgs.alpinelinux.org/packages?name=zbar&branch=edge

Seems to be fixed now.

For the hassio fix, we will probably have to wait until the package reaches main (if ever).

Is there any chance, it will be part of hassio?

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Still waiting on the fix for this

Was this page helpful?
0 / 5 - 0 ratings