如何安装源自apt包的Python绑定? [英] How to install Python bindings originating from an apt package?
问题描述
我有一个网站托管在 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
,这是(据我所知)ZAR包的python绑定(此处的Pipi链接)。我很惊讶,zbar或其python绑定不在列表中,而 python-qrtools
apt包。所以我的第一个问题:
这个zbar软件包安装的时间和地点在哪里?
这个ZBar buildpack 安装ZBar,所以我只需要安装zbar的Python绑定。从python命令行我已经看到它是源自.so文件的绑定:
>>>导入zbar
>>> zbar .__ file__
'/usr/lib/python2.7/dist-packages/zbar.so'
所以我做了一个简单的 sudo pip install zbar
,这不幸导致我下面粘贴了大量的编译错误。所以我的主要问题实际上是如下:
如何单独安装zbar python绑定(所以没有apt)?所有提示都是欢迎!
下载/拆包zbar
下载zbar-0.10.tar.bz2
运行setup.py(path:/tmp/pip_build_root/zbar/setup.py)egg_info for package zbar
安装收集的包:zbar
运行setup.py install for zbar
构建'zbar'扩展
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
在zbarmodule.c中包含的文件中:24:0:
zbarmodule.h:26:18 :致命错误:zbar.h:没有这样的文件或目录
#include< zbar.h>
^
编译终止。
错误:命令'x86_64-linux-gnu-gcc'失败,退出状态1
完成输出命令/ usr / bin / python -cimport setuptools,tokenize; __ file __ ='/ tmp / pip_build_root /zbar/setup.py';exec(compile(getattr(tokenize,'open',open)(__ file __)。read()。replace('\r\\\
','\\\
'),__file__, 'exec'))install --record /tmp/pip-zIuGzw-record/install-record.txt - 单一版本 - 外部管理--compile:
运行安装
运行build
运行build_ext
构建'zbar'扩展
创建构建
创建构建/ 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
在zbarmodule.c中包含的文件中:24:0:
zbarmodule.h:26:18:致命错误:zbar.h:没有这样的文件或目录
#includ e< zbar.h>
^
编译终止。
错误:命令'x86_64-linux-gnu-gcc'失败,退出状态1
所以我试图使用
分别安装Python zbar绑定不幸的是,我甚至似乎无法在linux上安装zbar软件包
sudo apt-get install libzbar-dev
sudo pip install zbar
通常是一个-dev包,当您收到这些错误时,您会丢失一个简单的方法软件包是 apt-cache search
如下所示:
〜$ apt -cache search zbar
libbarcode-zbar-perl - 条形码扫描器和解码器(Perl绑定)
libzbar-dev - 条形码扫描器和解码器(开发)
libzbar0 - 条码扫描器和解码器(库)
libzbargtk-dev - 条码扫描器和解码器(GTK +绑定开发)
libzbargtk0 - 条形码扫描器和解码器(GTK +绑定)
libzbarqt-dev - 条形码扫描器和解码器(Qt绑定开发)
libzbarqt0 - 条形码扫描器和解码器(Qt绑定)
python-qrtools - 用于读取和生成QR码的高级库
python-zbar - 条形码扫描器和解码器(Python绑定)
python-zbarpygtk - 条形码扫描器和解码器(PyGTK绑定)
zbar-dbg - 条形码扫描器和解码器(调试)
zbar-tools - 条码扫描器和解码器(实用程序)
FWIW,我用来安装的程序是 python-qrtools
, libzbar-dev
最后 pip install zbar
p>
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
.
这篇关于如何安装源自apt包的Python绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!