[英]pyzbar missing a module attribute that does actually exist?
Win 10 x64, Python 2.7, Spyder IDE Win 10 x64、Python 2.7、Spyder IDE
I'm using some code from Adrian Rosebrock's OpenCV blog...我正在使用 Adrian Rosebrock 的 OpenCV 博客中的一些代码......
import pyzbar
import cv2
# load the input image
image = cv2.imread("barcode_example.png")
# find the barcodes in the image and decode each of the barcodes
barcodes = pyzbar.pyzbar.decode(image)
# loop over the detected barcodes
for barcode in barcodes:
# extract the bounding box location of the barcode and draw the
# bounding box surrounding the barcode on the image
(x, y, w, h) = barcode.rect
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
# the barcode data is a bytes object so if we want to draw it on
# our output image we need to convert it to a string first
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
# draw the barcode data and barcode type on the image
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (0, 0, 255), 2)
# show the output image
cv2.imshow("Image", image)
cv2.waitKey(0)
I keep getting the following error...我不断收到以下错误...
AttributeError: 'module' object has no attribute 'pyzbar'
Yet when I check the module in Spyder it does indeed have said artibute...然而,当我检查 Spyder 中的模块时,它确实已经说过了...
I've tried running from the command line with the same result.我试过从命令行运行,结果相同。
I have also checked to see if my installation of zbar is working & it is with no problems我还检查了我的 zbar 安装是否正常工作并且没有问题
Is this an issue with the Python bindings or something really obvious?这是 Python 绑定的问题还是非常明显的问题?
Try:尝试:
import pyzbar.pyzbar as pyzbar
Works for me.为我工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.