python - import pyzbar.pyzbar - 找不到 zbar 共享库

标签 python computer-vision google-colaboratory qr-code

我想制作一个脚本来检测和读取照片中的二维码。我想为此使用 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

提前感谢您的回答

最佳答案

!pip install pyzbar之前,你需要用这个命令安装libzbar。

!apt install libzbar0

那么,pyzbar 应该可以工作了。

关于python - import pyzbar.pyzbar - 找不到 zbar 共享库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63217735/

相关文章:

Python:为控制台打印编写单元测试

python - 在机器人框架中记录 HTML 请求

python - Google App Engine Python 中使用区域设置的货币格式

opencv - 如何使用远距离的一个点(使用opencv)来计算相机方向?

python - CNN 使用具有显着尺寸差异的图像

python - 模块未找到错误: No module named 'nets' on Google Colab

python - 使用带有 TLS 的请求不会提供 SNI 支持

machine-learning - ARKit 图像检测 - 许多图像

python - key 错误 : "Invalid split train[:80%]. Available splits are: [' train']"

python - Google Colab - 从 GitHub 安装? GLRM