How to Install pyzbar in Python
Read one-dimensional barcodes and QR codes from Python 2 and 3.
pip install pyzbar
What is pyzbar?
Read one-dimensional barcodes and QR codes from Python 2 and 3.
Read one-dimensional barcodes and QR codes from Python 2 and 3 using the library.
- Pure python - Works with PIL / Pillow images, OpenCV / imageio / numpy ``\ s, and raw bytes - Decodes locations of barcodes - No dependencies, other than the zbar library itself - Tested on Python 2.7, and Python 3.5 to 3.10
The older package is stuck in Python 2.x-land. The package does not provide support for Windows and depends upon Pillow.
Quick Start
Minimal example to get started with pyzbar:
import pyzbar
print(pyzbar.__version__)
Installation
pip (standard)
pip install pyzbar
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install pyzbar
pip3
pip3 install pyzbar
conda
conda install -c conda-forge pyzbar
Poetry
poetry add pyzbar
Dependencies
Installing pyzbar will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import pyzbar; print(pyzbar.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing pyzbar with pip.
ModuleNotFoundError: No module named 'pyzbar'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install pyzbar. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'pyzbar' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install pyzbar to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'pyzbar'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show pyzbar and upgrade with pip install --upgrade pyzbar.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install pyzbar. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user pyzbar
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pyzbar
Recent Releases
| Version | Released |
|---|---|
0.1.9 latest |
2022-03-15 |
0.1.8 |
2019-02-21 |
0.1.7 |
2018-05-13 |
0.1.5 |
2018-03-18 |
0.1.4 |
2017-01-18 |
Manage pyzbar
Upgrade to latest version
pip install --upgrade pyzbar
Install a specific version
pip install pyzbar==0.1.9
Uninstall
pip uninstall pyzbar
Check what is installed
pip show pyzbar