我有一个托管在Heroku的网站,现在我想使用python-qrtools
包,该包使用ZBar条形码扫描器。在常规的Debian(基于)上,我可以执行以下简单操作:
sudo apt-get install python-qrtools
根据命令
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
当我查看
qrtools.py
的导入时,它还会进行import zbar
,据我所知,这是Zbar包的Python绑定(Pypi链接在此处)。但我有些惊讶的是,zbar或其Python绑定居然没有出现在python-qrtools
apt软件包列表中。所以我的第一个问题是:
这个zbar软件包是何时、何地安装的?
接下来,我决定在Heroku上安装ZBar和其Python绑定。我使用这个ZBar构建包成功安装了ZBar,因此我只需要安装zbar Python绑定。从Python命令行中,我已经看到它是从.so文件衍生的绑定。>>> import zbar
>>> zbar.__file__
'/usr/lib/python2.7/dist-packages/zbar.so'
所以我做了一个简单的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
所以我尝试单独安装Python zbar绑定
不幸的是,我甚至无法在Linux上安装zbar包
python-qrtools
,从 Python 命令行运行import zbar
是可以工作的。所以我猜测似乎不需要libzbar-dev
。 - kramer65libzbar-dev
,我无法使用pip编译zbar。Python-rtools仅安装了zbar绑定,而没有开发头文件。 - Padraic Cunningham