AttributeError:模块“zbar”没有属性“ImageScanner”

2024-04-30 06:10:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着运行这个代码

import pyqrcode
from qrtools import qrtools
from PIL import Image
import zbar
qr = pyqrcode.create("She got two litle horns and they get me a litle bit")
qr.png("horn.png", scale=6)
qr = qrtools.QR()
scanner = zbar.Scanner()
qr.decode("horn.png")
print(qr.data)

它告诉我

^{pr2}$

我正在运行最新的Ubuntux64并安装了所有依赖项,这是因为我正在尝试python3


Tags: 代码fromimageimportpilpngcreateqr
1条回答
网友
1楼 · 发布于 2024-04-30 06:10:52

显然,你必须使用python2并用ubuntu包管理器安装zbar

sudo apt-get install python-zbar

我在我的Ubuntu17.10机器上测试了它,它与python2一起工作。Python3似乎不起作用,看这里,他们有相同的问题:Can't install zbar

通过在终端中键入以下内容,确保运行的是正确的python版本:

^{pr2}$

它必须说明:python2.7.X,其中X在我的机器上是14

相关问题 更多 >