如何安装源自 apt 包的 Python 绑定? [英] How to install Python bindings originating from an apt package?

查看:15
本文介绍了如何安装源自 apt 包的 Python 绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 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 绑定.我设法使用 this 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为包 zbar 运行 setup.py(路径:/tmp/pip_build_root/zbar/setup.py)egg_info安装收集的软件包:zbar为 zbar 运行 setup.py install构建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 ^编译终止.错误:命令x86_64-linux-gnu-gcc"失败,退出状态为 1命令的完整输出/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-版本外部管理--编译:运行安装运行构建运行 build_ext构建zbar"扩展创建构建创建 build/temp.linux-x86_64-2.7x86_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 ^编译终止.错误:命令x86_64-linux-gnu-gcc"失败,退出状态为 1

所以我尝试使用

单独安装Python zbar绑定

不幸的是,我什至无法在 linux 上安装 zbar 包

解决方案

sudo apt-get install libzbar-dev须藤 pip 安装 zbar

当您遇到此类错误时,通常会丢失一个 -dev 包,找到该包的简单方法是 apt-cache search,如下所示:

~$ apt-cache search zbarlibbarcode-zbar-perl - 条码扫描器和解码器(Perl 绑定)libzbar-dev - 条码扫描器和解码器(开发)libzbar0 - 条码扫描器和解码器(库)libzbargtk-dev - 条码扫描器和解码器(GTK+ 绑定开发)libzbargtk0 - 条码扫描器和解码器(GTK+ 绑定)libzbarqt-dev - 条码扫描器和解码器(Qt 绑定开发)libzbarqt0 - 条码扫描器和解码器(Qt 绑定)python-qrtools - 用于读取和生成二维码的高级库python-zbar - 条码扫描器和解码器(Python 绑定)python-zbarpygtk - 条码扫描器和解码器(PyGTK 绑定)zbar-dbg - 条码扫描器和解码器(调试)zbar-tools - 条码扫描器和解码器(实用程序)

FWIW,我用来安装的程序是 python-qrtoolslibzbar-dev 和最后 pip install zbar.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆