CentOS安装zbar及pyzbar
  bDQnVrJUSZXY 2023年11月02日 64 0


CentOS安装zbar

安装zbar

方法一
sudo yum update

sudo yum install python3-devel
sudo yum install zbar-devel
sudo yum install zbar
pip install

不知为何我执行上面指令出现:No package zbar/zbar-devel available.
直接执行​​​pip install pyzbar​​报错:

for zbar (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/xxx/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t92p/pip-install-t92qoloh/zbar/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-10v4q07g
cwd: /tmp/pip-install-t92qoloh/zbar/
Complete output (13 lines):
running bdist_wheel
running build
running build_ext
building 'zbar' extension
creating build
creating build/temp.linux-x86_64-3.6
gcc -pthread -B /home/xxx/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrictinclude/python3.6m -c zbarmodule.c -o build/temp.linux-x86_64-3.6/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 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for
方法二

zbar 源码下载地址:​​http://zbar.sourceforge.net/download.html​​ 使用root权限如下执行:

tar -zxvf zbar-0.10.tar.gz
./configure --without-gtk --without-qt --disable-video
make &&make install

此时执行​​pip install pyzbar​​报错:

Installing collected packages: zbar
Running setup.py install for zbar ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-fob0go9_/zbar/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-6cnzewut-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-3.6
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -c zbarmodule.c -o build/temp.linux-x86_64-3.6/zbarmodule.o
In file included from zbarmodule.c:24:0:
zbarmodule.h:42:5: error: unknown type name ‘PyIntObject’
PyIntObject val; /* integer value is super type */
^
zbarmodule.c: In function ‘initzbar’:
zbarmodule.c:112:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
return;
^
zbarmodule.c:115:34: error: ‘PyInt_Type’ undeclared (first use in this function)
zbarEnumItem_Type.tp_base = &PyInt_Type;
^
zbarmodule.c:115:34: note: each undeclared identifier is reported only once for each function it appears in
zbarmodule.c:129:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
return;
^
zbarmodule.c:137:13: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
return;
^
zbarmodule.c:146:5: warning: implicit declaration of function ‘Py_InitModule’ [-Wimplicit-function-declaration]
PyObject *mod = Py_InitModule("zbar", zbar_functions);
^
zbarmodule.c:146:21: warning: initialization makes pointer from integer without a cast [enabled by default]
PyObject *mod = Py_InitModule("zbar", zbar_functions);
^
zbarmodule.c:148:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
return;
^
error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-fob0go9_/zbar/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-6cnzewut-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-fob0go9_/zbar/

重新执行,不知道怎么回事又安装成功了,真是瞎猫碰见死耗子。

python环境中执行​​from pyzbar.pyzbar import decode​​​报错:
​​​OSError: libzbar.so.0: cannot open shared object file: No such file or directory​​​ 执行:​​sudo ldconfig /usr/local/lib​​即可。

rpm安装 下载地址:​​【点击】​​ 这个方法会缺少依赖包,会很麻烦。

pyzbar使用方法

pyzbar简单使用方法:​​https://pypi.org/project/pyzbar/​

from pyzbar.pyzbar import decode
from PIL import Image

decode(Image.open('pyzbar/tests/code128.png'))

yum 安装软件时,报错:No package XXX available.
解决方法:​​​sudo yum install epel-release​


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  9E2BTpjt8nym   2023年12月06日   35   0   0 WindowsgitCentOS
bDQnVrJUSZXY