Python Barcode Scanner SDK

Add offline 1D and 2D barcode scanning to your Python scripts, Jupyter notebooks and batch import pipelines. Install prebuilt MIT-licensed PyO3 wheels from PyPI, pass label bytes or RGBA frames in process and retain every identifier as an exact string.

Python
import qrcode_barcode_scanner as qr

report = qr.scan(image_bytes, profile="frame")
code = next((d for d in report["detections"]
             if d["symbology"] == "code128"), None)

if code is not None:
    print(code["content"]["text"])

Inspect the decoded identifierSTOCK-4827

Read label images

Pass PNG, JPEG, WebP or GIF bytes to scan(). A Code 128 label encoding STOCK-4827 returns that exact string inside the report dict.

pip install qrcode-barcode-scanner

Need to scan a barcode right away? Open online reader

Python Barcode Scanner SDK at a glance

  • Prebuilt PyO3 wheels, no Rust needed

    PyPI wheels

  • Scripts, notebooks & batch imports

    Python 3.8+

  • EAN, UPC, Code 128, Data Matrix & more

    1D + 2D

  • Open-source licence

    MIT

Add native barcode scanning to Python

Decode 1D and 2D barcode labels across Python scripts, notebooks and batch pipelines with prebuilt PyO3 Rust wheels.

Read label images

Pass PNG, JPEG, WebP or GIF bytes to scan(). A Code 128 label encoding STOCK-4827 returns that exact string inside the report dict.

Scan raw RGBA frames

Pass RGBA pixel bytes with width and height to scan_frame() for OpenCV or camera pipelines without re-encoding image files.

Keep exact strings & formats

Keep decoded text as Python str values instead of casting to int so UPC and EAN leading zeros stay intact for database lookups.

Add barcode image reading in Python

Install prebuilt wheels from PyPI, pass formats to scan() and keep every decoded identifier as an exact string.

Install the Python package from PyPI

Create a virtual environment with CPython 3.8 or newer and install qrcode-barcode-scanner on PyPI. Prebuilt wheels cover macOS ARM64/x64, GNU/Linux ARM64/x64, musl Linux x64 and Windows x64.

To test in a browser notebook first, open the Google Colab interactive notebook, run it on Binder or browse Barcode Scanner Examples.

pip install qrcode-barcode-scanner

Install qrcode-barcode-scanner (hyphens) and import qrcode_barcode_scanner (underscores).

Passing --only-binary=:all: prevents pip from triggering a local Rust source build on unsupported platforms.

Decode a barcode image in Python

Pass encoded label bytes (PNG, JPEG, WebP or GIF) to scan() with formats listing only the barcode symbologies you require. No reader outside that list executes.

To prepare a known test fixture, generate a Code 128 barcode with Code 128 Barcode Generator encoding STOCK-4827 and test the exported PNG.

Python
from __future__ import annotations
from pathlib import Path
import qrcode_barcode_scanner as qr

FORMATS = ["code128", "code39", "ean13", "ean8", "upc_a", "upc_e", "itf", "data_matrix"]

def read_barcodes(path: str) -> list[tuple[str, str]]:
    image_bytes = Path(path).read_bytes()
    report = qr.scan(
        image_bytes,
        profile="frame",
        formats=FORMATS,
        max_dimension=4096,
        max_pixels=16_000_000,
    )
    return [
        (d["symbology"], d["content"]["text"])
        for d in report["detections"]
        if d["content"]["charset"] != "unknown"
    ]

Switch to profile="full" (or budget_ms=0) for low-contrast, angled or worn label photos.

Add pdf417, aztec, code93, codabar, data_bar, data_bar_expanded, telepen or maxi_code to FORMATS whenever your pipeline requires them.

Inspect the decoded identifier

For a Code 128 label encoding STOCK-4827, read_barcodes returns [("code128", "STOCK-4827")]. A UPC-A value such as 012345678905 stays a Python str with its leading zero intact.

A blank image or excluded symbology returns [] (confirm report["trace"]["budget_exhausted"] is False). Unreadable bytes or unknown formats raise ValueError ending in a QRS-xxx code.

Barcode coverage, RGBA frames and data integrity

Sixteen barcode formats. Decodes EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode (ISBN maps to ean13, GS1-128 to code128 and ITF-14 to itf).

Strings and input caps. Keep identifiers as Python str when writing to CSV or DataFrames so leading zeros are never stripped, and keep product lookups separate. Lower max_dimension and max_pixels from 10,000 px / 64M pixels for untrusted uploads.

RGBA frames and MIT licence. Call scan_frame() for raw pixel buffers and inspect content["raw"] when charset is unknown. Current releases ship under the MIT licence; see the Python package README and Python API documentation.

Python Barcode Scanner documentation and licence

Official package guides, ScanReport specification and licensing references.

Python Barcode Scanner SDK questions

PyPI wheels, formats, leading zeros, RGBA frames, notebooks and licensing.

It is QR Code AI’s open-source MIT-licensed PyO3 extension (qrcode-barcode-scanner on PyPI, imported as qrcode_barcode_scanner) for decoding 16 1D and 2D barcode formats alongside QR codes in Python 3.8+.

It decodes EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode, plus QR Code, Micro QR and rMQR. Pass formats to restrict active readers.

Prebuilt CPython 3.8+ wheels cover macOS ARM64/x64, GNU/Linux ARM64/x64, musl Linux x64 and Windows x64. Add --only-binary=:all: to guarantee pip installs a prebuilt wheel instead of compiling Rust locally.

No. It returns each encoded identifier as a Python str alongside its symbology (plus parsed GS1 fields when recognised). Never cast barcode text to int so leading zeros survive, and query your own catalogue database separately.

Yes. Convert your OpenCV or Pillow frame into raw RGBA bytes and pass it with width and height to scan_frame(rgba, width, height, profile="frame"). It decodes caller-supplied frames without opening a camera or drawing an overlay.

An image with no matching barcode returns an empty detections list (verify report["trace"]["budget_exhausted"] is False). Unreadable bytes, oversized images or unknown format names raise ValueError carrying a QRS-xxx code.

No. The compiled PyO3 extension runs 100% locally in process with zero network requests, no QR Code AI account, no API key and no creation credits.

Yes. Current releases ship under the MIT licence for commercial and proprietary Python pipelines while keeping copyright and licence notices intact (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.