pyzxing
Reliable Python bindings for the ZXing barcode decoder. pyzxing exposes a stable Python API while delegating decoding to a versioned, checksum-verified Java Runner.
Features
- Decode one image or a glob of images into one consistent result list.
- Read QR Code, Data Matrix, PDF417, Aztec, and common one-dimensional formats.
- Accept file paths and NumPy arrays.
- Preserve binary payloads, byte segments, result points, metadata, and orientation.
- Control ZXing with explicit format, charset, multi-code, and effort hints.
- Run on Linux, macOS, and Windows with Python 3.8–3.14 and Java 17+.
- Install a pinned Runner automatically, or receive it directly from conda-forge.
Requirements
| Component | Supported versions |
|---|---|
| Python | 3.8–3.14 |
| Java | 17 or newer |
| Operating systems | Linux, macOS, Windows |
| ZXing runtime | 3.5.4 in pyzxing 1.2.x |
Java must be available as java on PATH. The Python package downloads the
matching Runner on first use and verifies its SHA-256 checksum. The conda-forge
package installs that Runner inside the environment.
Installation
Install from PyPI:
python -m pip install pyzxing
Or install from conda-forge:
conda install -c conda-forge pyzxing
Quick start
from pyzxing import BarCodeReader
reader = BarCodeReader()
results = reader.decode("/path/to/qrcode.png")
for result in results:
print(result["format"], result["text"])
Globs return the same flat list[dict] shape:
results = reader.decode("/path/to/images/*.png")
Pass decode hints explicitly when needed:
results = reader.decode(
"/path/to/barcode.png",
multi=True,
try_harder=True,
character_set="UTF-8",
possible_formats=["QR_CODE", "DATA_MATRIX"],
)
NumPy arrays
Install OpenCV and pass an RGB or grayscale array:
python -m pip install opencv-python
results = reader.decode_array(image)
Results
Every decoded barcode is represented by a dictionary. The most commonly used fields are:
| Field | Type | Purpose |
|---|---|---|
text |
str |
Decoded display text. |
format |
bytes |
ZXing barcode format. |
raw_bytes |
bytes | None |
Raw ZXing result bytes. |
byte_segments |
list[bytes] |
Lossless QR byte-mode segments. |
points |
list[tuple[float, float]] |
Result points reported by ZXing. |
orientation |
int | None |
Clockwise image rotation. |
metadata |
dict |
Stable ZXing result metadata. |
The legacy byte-valued raw and parsed fields remain available for backward
compatibility. Use byte_segments for binary QR payloads instead of re-encoding
text.
Documentation
The complete guide is available on Read the Docs:
- Installation and runtime requirements
- Usage and decode hints
- Result schema
- API reference
- PyInstaller and deployment
- Troubleshooting
Command-line examples
Scan a file:
python scripts/scanner.py -f /path/to/barcode.png
Sample frames from a webcam:
python -m pip install opencv-python
python scripts/webcam_demo.py --camera 0 --interval 0.5
The webcam example uses the existing one-shot decode_array() API. It does not
keep a persistent Java process running.
Development
python -m pip install -e '.[dev]'
./mvnw -f java-runner/pom.xml clean verify
python -m pytest tests/
Use mvnw.cmd instead of ./mvnw on Windows. See
the development guide
for documentation builds and release checks.
Project links
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyzxing-1.2.2.tar.gz.
File metadata
- Download URL: pyzxing-1.2.2.tar.gz
- Upload date:
- Size: 642.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b5cf7427dbbb545a6d2d70dc2fda1a2d4e8b0715c63795a3d8f7b86c3b1a3ef
|
|
| MD5 |
ba304fb2da1cb3782ca8ff8f591f1d29
|
|
| BLAKE2b-256 |
0b99a565f3d7359e081217049390c795a813bc99c84053246f43f7c1c5dee31b
|
Provenance
The following attestation bundles were made for pyzxing-1.2.2.tar.gz:
Publisher:
ci-cd.yml on ChenjieXu/pyzxing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyzxing-1.2.2.tar.gz -
Subject digest:
0b5cf7427dbbb545a6d2d70dc2fda1a2d4e8b0715c63795a3d8f7b86c3b1a3ef - Sigstore transparency entry: 2190319261
- Sigstore integration time:
-
Permalink:
ChenjieXu/pyzxing@0f7e3138f0ac3eaaa2c970dcdb52e4a580a4ebda -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ChenjieXu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@0f7e3138f0ac3eaaa2c970dcdb52e4a580a4ebda -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pyzxing-1.2.2-py3-none-any.whl.
File metadata
- Download URL: pyzxing-1.2.2-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28daed31a0ab09a4d9c501efe9f1552f97faf37114f35ce0c37567834c8fca3c
|
|
| MD5 |
4604d1c4292e3df019e7c14e36b398d2
|
|
| BLAKE2b-256 |
9067e09b8b159e581c2571ca0f927bb1cbe929ddfb3a8ea5828a097c1a1a039c
|
Provenance
The following attestation bundles were made for pyzxing-1.2.2-py3-none-any.whl:
Publisher:
ci-cd.yml on ChenjieXu/pyzxing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyzxing-1.2.2-py3-none-any.whl -
Subject digest:
28daed31a0ab09a4d9c501efe9f1552f97faf37114f35ce0c37567834c8fca3c - Sigstore transparency entry: 2190319605
- Sigstore integration time:
-
Permalink:
ChenjieXu/pyzxing@0f7e3138f0ac3eaaa2c970dcdb52e4a580a4ebda -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ChenjieXu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@0f7e3138f0ac3eaaa2c970dcdb52e4a580a4ebda -
Trigger Event:
workflow_dispatch
-
Statement type: