Python Barcode Scanner SDK

Add offline 1D and 2D barcode scanning to your Python scripts, notebooks and batch import pipelines. Install pre-built MIT-licensed PyO3 wheels from PyPI, pass label bytes or RGBA frames in process and keep 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 in the report dict.

pip install qrcode-barcode-scanner

Want to scan a barcode now? Open the online reader

Python Barcode Scanner SDK at a glance

  • Pre-built 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 pipelines with pre-built 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 in the report dict.

Scan raw RGBA frames

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

Keep exact strings & formats

Preserve barcode text as Python str values instead of coercing to int so UPC and EAN leading zeros stay intact for database lookups.

Add barcode image reading in Python

Install pre-built wheels from PyPI, pass formats to scan() and keep decoded identifiers as exact strings.

Install the Python package from PyPI

Create a virtual environment with CPython 3.8 or later and install qrcode-barcode-scanner on PyPI. Pre-built 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 notebook, launch it on Binder or browse the Barcode Scanner examples.

pip install qrcode-barcode-scanner

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

Using --only-binary=:all: avoids unexpected local Rust source compilation on unsupported platforms.

Decode a barcode image in Python

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

To prepare a known 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"
    ]

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

Add pdf417, aztec, code93, codabar, data_bar, data_bar_expanded, telepen or maxi_code to FORMATS when your workflow needs them.

Inspect the decoded identifier

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

A blank image or unrequested symbology returns [] (verify 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, ITF-14 to itf).

Strings and input caps. Keep identifiers as Python str when exporting to CSV or dataframes so leading zeros never vanish, 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 read content["raw"] when charset is unknown. Current releases are MIT-licensed; see the Python package README and Python API docs.

Python Barcode Scanner documentation and licence

Official package documentation, 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 PyO3 extension (qrcode-barcode-scanner on PyPI, imported as qrcode_barcode_scanner) for decoding 16 1D and 2D barcode formats plus QR codes in Python 3.8+.

It reads 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.

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

No. It neither looks up product names nor strips leading zeros: it returns each encoded identifier as a Python str with its symbology (and parsed GS1 fields when recognised). Never coerce barcode text to int, and query your own catalogue or stock database separately.

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

An image with no matching barcode returns an empty detections list (confirm report["trace"]["budget_exhausted"] is False). Corrupt or 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 calls, requiring no internet access, QR Code AI account, API key or creation credits.

Yes. Current releases are MIT-licensed for commercial and proprietary applications while retaining copyright and licence notices (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.