import pyzbar.pyzbar – Unable to find zbar shared library
Question:
I want to make a script for detecting and reading QR codes from photos. I would like to use PyZbar for that, but I have a problem with some errors.
I’m working in google colaboratory
!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
this is an error I’m struggling with:
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
Thank You ind advance for your answers
Answers:
Before you can !pip install pyzbar
, you need to install libzbar with this command.
!apt install libzbar0
Then, pyzbar should work.
I had the same issue working on Amazon SageMaker, these commands worked for me
# First install zbar
!sudo apt-get install libzbar-dev -y
!sudo yum install zbar-devel -y
# Then install pyzbar
!pip install pyzbar
This solved it for me on Mac:
mkdir ~/lib
ln -s $(brew --prefix zbar)/lib/libzbar.dylib ~/lib/libzbar.dylib
From https://github.com/npinchot/zbar/issues/3#issuecomment-1038005495
For me, this worked on macOS
step1:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
step2:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
step3:
brew install zbar
I want to make a script for detecting and reading QR codes from photos. I would like to use PyZbar for that, but I have a problem with some errors.
I’m working in google colaboratory
!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
this is an error I’m struggling with:
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
Thank You ind advance for your answers
Before you can !pip install pyzbar
, you need to install libzbar with this command.
!apt install libzbar0
Then, pyzbar should work.
I had the same issue working on Amazon SageMaker, these commands worked for me
# First install zbar
!sudo apt-get install libzbar-dev -y
!sudo yum install zbar-devel -y
# Then install pyzbar
!pip install pyzbar
This solved it for me on Mac:
mkdir ~/lib
ln -s $(brew --prefix zbar)/lib/libzbar.dylib ~/lib/libzbar.dylib
From https://github.com/npinchot/zbar/issues/3#issuecomment-1038005495
For me, this worked on macOS
step1:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
step2:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
step3:
brew install zbar