gpt4 book ai didi

python - 如何安装源自 apt 包的 Python 绑定(bind)?

转载 作者:IT王子 更新时间:2023-10-29 00:19:59 26 4
gpt4 key购买 nike

我有一个托管在 Heroku 的网站,我现在想使用 python-qrtools 包,它使用 ZBar bar code scanner .在常规的 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 绑定(bind)包(Pypi link here)。我有点惊讶 zbar 或其 python 绑定(bind)不在 python-qrtools apt 包的列表中。所以我的第一个问题:

此 zbar 包何时何地安装?

继续我决定在 Heroku 上安装 ZBar 和它的 python 绑定(bind)。我设法使用 this ZBar buildpack 安装了 ZBar所以我只需要安装 zbar Python 绑定(bind)。从 python 命令行我已经看到它是一个源自 .so 文件的绑定(bind):

>>> import zbar
>>> zbar.__file__
'/usr/lib/python2.7/dist-packages/zbar.so'

所以我做了一个简单的 sudo pip install zbar,不幸的是导致了一个巨大的编译错误,我将其粘贴在下面。所以我的主要问题实际上是:

我如何单独安装 zbar python 绑定(bind)(所以没有 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 绑定(bind)

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

最佳答案

sudo apt-get install libzbar-dev
sudo pip install zbar

当您遇到此类错误时,通常是缺少一个 -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)

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

关于python - 如何安装源自 apt 包的 Python 绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27406641/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com