Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python barcode libraries generate barcode and QR code images and decode them from photos or scans. A generator encodes the data as bars or modules and writes the result to SVG, PNG, or PDF. These libraries let inventory, ticketing, and shipping systems print and scan codes from Python.
Popularity
qrcode has the most monthly downloads among dedicated barcode and QR code libraries in this comparison, at 36.5M.
@validate_call(config=PYDANTIC_CONFIG)
def make_qr(data: Any, qr_code_options: QRCodeOptions, force_text: bool = True):
"""Creates a QR code that encodes the given `data` with the given `qr_code_options`.
:param str data: The data to encode
:param qr_code_options: Options to create and serialize the QR code.
:param bool force_text: Tells whether we want to force the `data` to be considered as text string and encoded in byte mode.
:rtype: segno.QRCode
"""
# WARNING: For compatibility reasons, we still allow to pass __proxy__ class (lazy string). Moreover, it would be # OK to pass anything that has __str__ attribute (e.g. class instance that handles phone numbers). if force_text:
return segno.make(str(data), **qr_code_options.kw_make(), mode="byte")
return segno.make(data, **qr_code_options.kw_make())
zxing-cpp
Provides Python bindings for reading and generating barcode images with ZXing-C++.
Downloads / mo
5.9M
Stars
2.1K
Last release
3.1.1
License
Apache-2.0
Strengths
Reads and writes barcodes.Decode image data or construct a barcode for rendering.
def read_barcodes_zxing(image: Image.Image) -> list[tuple[str, str]]:
"""
Returns the text and format (zxing enum name) of each barcode found in
the image
"""
barcodes = []
import zxingcpp
detected_barcodes = zxingcpp.read_barcodes(image)
for barcode in detected_barcodes:
if barcode.text:
barcodes.append((barcode.text, barcode.format.name))
logger.debug(
f"Barcode of type {barcode.format} found: {barcode.text}",
)
return barcodes
pyzbar
Reads linear barcodes and QR codes through the ZBar library.
Downloads / mo
3.0M
Stars
831
Last release
0.1.9
License
MIT
Strengths
Returns barcode locations.Use rectangle and polygon coordinates alongside each decoded payload.
Accepts common image objects.Decode Pillow images, image arrays, or raw pixel buffers.
Limitations
Unix systems need ZBar installed.Install the shared library separately on non-Windows systems.
Bundled Windows builds omit orientation.Bundled Windows DLLs cannot report barcode orientation.
@staticmethod
def read_barcodes_pyzbar(image: Image.Image) -> list[str]:
barcodes = []
from pyzbar import pyzbar
# Decode the barcode image detected_barcodes = pyzbar.decode(image)
# Traverse through all the detected barcodes in image for barcode in detected_barcodes:
if barcode.data:
decoded_barcode = barcode.data.decode("utf-8")
barcodes.append(decoded_barcode)
logger.debug(
f"Barcode of type {barcode.type} found: {decoded_barcode}",
)
return barcodes
python-barcode
Generates barcodes with vector and optional raster image writers.
Downloads / mo
2.8M
Stars
659
Last release
0.16.1
License
MIT
Strengths
Creates SVG without external dependencies.Generate scalable barcode artwork without installing an image engine.
Calculates checksums automatically.Supply the barcode value without calculating its checksum yourself.
Limitations
Raster output needs Pillow.Install the images extra before generating raster images.
def _generate_qr_code(data: str) -> str:
"""Generate a base64 PNG string represent QR Code image of data."""
import pyqrcode # noqa: PLC0415
qr_code = pyqrcode.create(data)
with BytesIO() as buffer:
qr_code.svg(file=buffer, scale=4)
return str(
buffer.getvalue()
.decode("ascii")
.replace("\n", "")
.replace(
(
'<?xml version="1.0" encoding="UTF-8"?>'
'<svg xmlns="http://www.w3.org/2000/svg"'
),
"<svg",
)
)
FAQ
python-barcode suits generating linear barcodes such as EAN and UPC. Segno and qrcode suit QR codes. zxing-cpp suits reading and writing many barcode formats from one package.
Segno generates QR codes and Micro QR codes in pure Python. It writes SVG, PNG, and other formats with no extra dependencies.
Install qrcode or Segno, pass the text or URL, and save the result as an image. Both control error correction and module size.
pyzbar reads linear barcodes and QR codes from images through the ZBar library. It needs the ZBar shared library installed on the system.
python-barcode generates EAN, UPC, and other linear barcodes as SVG or, with Pillow, as raster images.
For coding agents
Found your barcode library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.