I've got a website hosted at Heroku, and I now want to use the python-qrtools
package which uses the ZBar bar code scanner. On a regular debian (based) I can do a simple:
sudo apt-get install python-qrtools
According to the command dpkg-query -L python-qrtools
, this installs the following:
/usr/lib/python2.7/dist-packages/qrtools-1.2.egg-info
/usr/lib/python2.7/dist-packages/qrtools.py
/usr/share/doc/python-qrtools/copyright
/usr/share/doc/python-qrtools/changelog.Debian.gz
When I look at the imports of qrtools.py
, it also does an import zbar
, which is (as far as I understand) the python binding for the Zbar package (Pypi link here). I'm kinda surprised that zbar or its python bindings are not in the list with the python-qrtools
apt package though. So my first question:
When and where is this zbar package installed?
Moving on I decided to install ZBar and the python binding for it on Heroku. I managed to install ZBar using this ZBar buildpack so I only need to instal the zbar Python binding. From the python command line I already see that it is a binding originating from a .so file:
>>> import zbar
>>> zbar.__file__
'/usr/lib/python2.7/dist-packages/zbar.so'
So I did a simple sudo pip install zbar
, which unfortunately results in a massive compiling error which I pasted below. So my main question is actually the following:
How do I install the zbar python bindings separately (so without apt)? All tips are welcome!
Downloading/unpacking zbar
Downloading zbar-0.10.tar.bz2
Running setup.py (path:/tmp/pip_build_root/zbar/setup.py) egg_info for package zbar
Installing collected packages: zbar
Running setup.py install for zbar
building 'zbar' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c zbarmodule.c -o build/temp.linux-x86_64-2.7/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 'x86_64-linux-gnu-gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/zbar/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zIuGzw-record/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-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c zbarmodule.c -o build/temp.linux-x86_64-2.7/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 'x86_64-linux-gnu-gcc' failed with exit status 1
So I tried to install the Python zbar binding separately using
Unfortunately I don't even seem to be able to install the zbar package on linux
sudo apt-get install libzbar-dev
sudo pip install zbar
It is usually a -dev package that you are missing when you get those kind of errors, an easy way to find the package is apt-cache search
like below:
~$ apt-cache search zbar
libbarcode-zbar-perl - bar code scanner and decoder (Perl bindings)
libzbar-dev - bar code scanner and decoder (development)
libzbar0 - bar code scanner and decoder (library)
libzbargtk-dev - bar code scanner and decoder (GTK+ bindings development)
libzbargtk0 - bar code scanner and decoder (GTK+ bindings)
libzbarqt-dev - bar code scanner and decoder (Qt bindings development)
libzbarqt0 - bar code scanner and decoder (Qt bindings)
python-qrtools - high level library for reading and generating QR codes
python-zbar - bar code scanner and decoder (Python bindings)
python-zbarpygtk - bar code scanner and decoder (PyGTK bindings)
zbar-dbg - bar code scanner and decoder (debug)
zbar-tools - bar code scanner and decoder (utilities)
FWIW, the procedure I used to install was python-qrtools
,libzbar-dev
and finally pip install zbar
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With