kra*_*r65 8 python linux debian apt zbar
我有一个在Heroku上托管的网站,现在我想使用python-qrtools
使用ZBar条形码扫描器的软件包.在普通的debian(基础)上,我可以做一个简单的事情:
sudo apt-get install python-qrtools
Run Code Online (Sandbox Code Playgroud)
根据该命令dpkg-query -L python-qrtools
,这将安装以下内容:
/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
Run Code Online (Sandbox Code Playgroud)
当我查看导入时qrtools.py
,它也会执行一次import zbar
,这是(据我所知)Zbar包的python绑定(这里是Pypi链接).我有点惊讶的是zbar或它的python绑定不在python-qrtools
apt包的列表中.所以我的第一个问题:
安装此zbar包的时间和地点?
继续我决定在Heroku上安装ZBar和python绑定.我设法使用这个ZBar buildpack安装ZBar 所以我只需要安装zbar Python绑定.从python命令行我已经看到它是一个源自.so文件的绑定:
>>> import zbar
>>> zbar.__file__
'/usr/lib/python2.7/dist-packages/zbar.so'
Run Code Online (Sandbox Code Playgroud)
所以我做了一个简单的sudo pip install zbar
,不幸的是导致了我粘贴在下面的大量编译错误.所以我的主要问题实际上如下:
如何单独安装zbar python绑定(所以没有apt)?欢迎所有提示!
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
Run Code Online (Sandbox Code Playgroud)
所以我尝试单独安装Python zbar绑定
不幸的是我似乎甚至无法在linux上安装zbar软件包
sudo apt-get install libzbar-dev
sudo pip install zbar
Run Code Online (Sandbox Code Playgroud)
它通常是一个-dev包,当你遇到这种错误时你会丢失,找到包的简单方法apt-cache search
如下所示:
~$ 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)
Run Code Online (Sandbox Code Playgroud)
FWIW,我以前安装的程序是 python-qrtools
,libzbar-dev
最后pip install zbar
.