我想做一个脚本,以检测和阅读QR代码从照片。我想为此使用PyZbar,但我对一些错误有问题。
我在谷歌公司工作
!sudo apt install tesseract-ocr
!pip install pytesseract
!pip install pyzbar[scripts]
import shutil
import os
import random
import re
import cv2
import numpy as np
import pytesseract
from pytesseract import Output
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
import glob
import pyzbar.pyzbar
from PIL import Image
这是我一直在努力解决的一个错误:
ImportError Traceback (most recent call last)
<ipython-input-25-d8758fa4db37> in <module>()
24 import glob
25 # ZBAR - Bar Code Reader is an open source software suite for reading bar codes from various sources, such as video streams, image files and raw intensity sensors
---> 26 import pyzbar.pyzbar
27 # PIL - Python Imaging Library
28 from PIL import Image
4 frames
/usr/local/lib/python3.6/dist-packages/pyzbar/zbar_library.py in load()
63 path = find_library('zbar')
64 if not path:
---> 65 raise ImportError('Unable to find zbar shared library')
66 libzbar = cdll.LoadLibrary(path)
67 dependencies = []
ImportError: Unable to find zbar shared library
谢谢您的提前答复。
发布于 2020-08-03 04:49:52
在您可以使用!pip install pyzbar
之前,您需要使用以下命令安装libzbar。
!apt install libzbar0
那么,pyzbar应该能工作。
发布于 2022-04-17 19:53:15
这解决了我在Mac上的问题:
mkdir ~/lib
ln -s $(brew --prefix zbar)/lib/libzbar.dylib ~/lib/libzbar.dylib
来自https://github.com/npinchot/zbar/issues/3#issuecomment-1038005495
发布于 2021-11-23 14:54:09
我在亚马逊的SageMaker上也遇到了同样的问题,这些命令对我来说是有效的。
# First install zbar
!sudo apt-get install libzbar-dev -y
!sudo yum install zbar-devel -y
# Then install pyzbar
!pip install pyzbar
https://stackoverflow.com/questions/63217735
复制相似问题