Python Barcode Scanner SDK

Add offline 1D and 2D barcode scanning to your Python scripts, Jupyter notebooks and batch ingestion pipelines. Install prebuilt MIT-licensed PyO3 wheels from PyPI, supply label bytes or RGBA frames in process and preserve 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

Supply 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 the 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 in Python scripts, notebooks and batch jobs using prebuilt PyO3 Rust wheels.

Read label images

Supply 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

Send raw RGBA pixel bytes with width and height to scan_frame() for OpenCV or camera-capture pipelines without re-encoding images.

Keep exact strings & formats

Keep decoded identifiers as Python str values instead of converting them to int so UPC and EAN leading zeros remain intact for catalogue lookups.

Add barcode image scanning in Python

Install prebuilt wheels from PyPI, pass formats to scan() and preserve decoded identifiers as exact strings.

Install the Python package from PyPI

Set up a virtual environment running CPython 3.8 or later and install qrcode-barcode-scanner on PyPI. Prebuilt wheels ship for macOS ARM64/x64, GNU/Linux ARM64/x64, musl Linux x64 and Windows x64.

To experiment inside a browser notebook first, open the Google Colab notebook, launch it on Binder or browse the Barcode Scanner examples.

pip install qrcode-barcode-scanner

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

Adding --only-binary=:all: prevents pip from triggering a local Rust compilation on unsupported hosts.

Decode a barcode image in Python

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

To prepare a known test fixture, create a Code 128 barcode with 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"
    ]

Use profile="full" (or budget_ms=0) for low-contrast, tilted or worn label photos.

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

Inspect the decoded identifier

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

A blank image or an unrequested symbology returns [] (confirm report["trace"]["budget_exhausted"] is False). Unreadable bytes or unknown formats raise ValueError ending with 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, ITF-14 to itf).

Strings and input caps. Keep identifiers as Python str when writing to CSV files or DataFrames so leading zeros never drop, and query product catalogues separately. Tighten max_dimension and max_pixels below 10,000 px and 64M pixels for untrusted uploads.

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

Python Barcode Scanner documentation and licence

Official package guides, ScanReport schema specification and licensing notices.

Python Barcode Scanner SDK questions

PyPI wheels, barcode 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 along with 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 run only selected 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 pulls a prebuilt wheel rather than compiling Rust from source.

No. It returns each encoded identifier as a Python str alongside its symbology (and parsed GS1 fields when recognised). Keep values as str instead of casting to int so leading zeros remain intact, and query your own product 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 pixels without opening a camera or rendering an overlay.

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

Yes. The compiled PyO3 extension executes 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 software while retaining copyright and licence notices (check LICENSING.md). SDK usage is independent of QR Code AI’s paid creation plans and seven-day Premium trial.