当尝试在Fedora Linux 26上的python下导入zbar时,我收到以下错误:
>>> import zbar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "zbar/__init__.py", line 1, in <module>
from .zbar import *
File "zbar/zbar.py", line 70, in <module>
_ZB = load_zbar()
File "zbar/zbar.py", line 63, in load_zbar
'\n\n'.join(err_txt))
RuntimeError: zbar/_zbar.c:
zbar/_zbar.c: invalid ELF header通过搜索这个问题的解决方案,我找到了推荐安装适当软件包的another StackOverflow question,但这并没有什么特别的帮助,因为我已经使用我的软件包管理器dnf安装了zbar和zbar-devel。我使用the module's website.上提供的单个指令安装了这个python库本身
“无效ELF报头”是什么意思?我应该采取哪些步骤来解决此问题?简而言之,我如何让zbar工作?
发布于 2018-01-24 02:09:42
通常,这意味着包是为与您使用的架构不同的架构构建的。http://zbar.sourceforge.net/download.html检查链接,我没有看到Fedora26列出。
基于Mattdm的评论:另一种可能性是Pypi包已经过时(2009年的最后更新)。您是通过最新版本的包管理器安装的,然后通过Pip (旧版本)执行安装。旧版本覆盖了正确的版本。Pypi包版本是0.10。fedora包版本应该类似于0.20。使用正确的pip版本运行pip freeze | grep zbar。
发布于 2018-01-24 02:23:14
看起来python绑定包含在上游zbar源代码中,但由于某些原因没有打包到Fedora中。(有一个zbar-pygtk,但我认为这不是您想要的。)我认为最好的办法是让Fedora (参见https://src.fedoraproject.org/rpms/zbar)中的包的维护者来构建python绑定。
看起来最新的上游版本大约是在十年前发布的,而PyPi模块似乎就是基于这个基础的。Fedora的包是较新的,基于https://linuxtv.org/downloads/zbar/的一些东西。从tarball中的NEWS文件:
version 0.20 (2017-04-11):
As upstream didn't have any version since 2009, created a ZBar fork at linuxtv.org. This release improves a lot V4L2 support, by using libv4l2
to handle formats that are alien to ZBar, making it compatible with a lot
more webcam models. Qt support was also updated, making it compatible
with Qt5. ZBar now have two other GUI applications (zbarcam-qt and
zbarcam-gtk). With zbarcam-qt, it is now possible to adjust the camera
controls, making easier to read barcodes using a camera.可能是旧的模块和新的(分支的) zbar不能很好地协同工作。如果“与打包者交谈”的方法不起作用,或者速度不够快,我建议删除Fedora包,从源代码构建zbar本身,然后重试。
https://stackoverflow.com/questions/48408128
复制相似问题