Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

python-zxing

PyPI Build Status License: LGPL v3

This is a wrapper for the ZXing barcode library. It will allow you to read and decode barcode images from Python.

It was originally a "slightly less quick-and-dirty" fork of oostendo/python-zxing, but has since evolved considerably beyond that ancestral package.

Dependencies and installation

Use the Python 3 version of pip (usually invoked via pip3) to install: pip3 install zxing

  • You'll neeed to have a recent java binary somewhere in your path. (Tested with OpenJDK v7, v8, v11.)
  • pip will automatically download the relevant JAR files for the Java ZXing libraries (currently v3.5.3)

Usage

The BarCodeReader class is used to decode images:

>>> import zxing
>>> reader = zxing.BarCodeReader()
>>> print(reader.zxing_version, reader.zxing_version_info)
3.5.1 (3, 5, 1)
>>> barcode = reader.decode("test/barcodes/QR_CODE-easy.png")
>>> print(barcode)
BarCode(raw='This should be QR_CODE', parsed='This should be QR_CODE', path='test/barcodes/QR_CODE-easy.png', format='QR_CODE', type='TEXT', points=[(15.0, 87.0), (15.0, 15.0), (87.0, 15.0), (75.0, 75.0)])

The attributes of the decoded BarCode object are raw, parsed, path, format, type, points, and raw_bits. The list of formats which ZXing can decode is here.

The decode() method accepts an image path or PIL Image object (or list thereof) and takes optional parameters try_harder (boolean), possible_formats (list of formats to consider), and pure_barcode (boolean). If no barcode is found, it returns a False-y BarCode object with all fields except path set to None. If it encounters any other recognizable error from the Java ZXing library, it raises BarCodeReaderException.

Command-line interface

The command-line interface can decode images into barcodes and output in either a human-readable or CSV format:

usage: zxing [-h] [-c] [--try-harder] [--pure-barcode] [-V] image [image ...]

Human-readable:

$ zxing /tmp/barcode.png
/tmp/barcode.png
================
  Decoded TEXT barcode in QR_CODE format.
  Raw text:    'Testing 123'
  Parsed text: 'Testing 123'

CSV output (can be opened by LibreOffice or Excel):

$ zxing /tmp/barcode1.png /tmp/barcode2.png /tmp/barcode3.png
Filename,Format,Type,Raw,Parsed
/tmp/barcode1.png,CODE_128,TEXT,Testing 123,Testing 123
/tmp/barcode2.png,QR_CODE,URI,http://zxing.org,http://zxing.org
/tmp/barcode3.png,QR_CODE,TEXT,"This text, ""Has stuff in it!"" Wow⏎Yes it does!","This text, ""Has stuff in it!"" Wow⏎Yes it does!"

License

LGPLv3

Metadata

Release files for zxing 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zxing 1.0.4
File Size Uploaded
zxing-1.0.4.tar.gz 696.6 kB Details

Release files / zxing-1.0.4.tar.gz

Download URL zxing-1.0.4.tar.gz
Size 696.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e588c7001f8d2f0f938f4066fa4270f29f641fd520f4f662620545d3fd72ae1a
BLAKE2b-256 checksum
How to use checksums
f86bfeb86fa135a34379cad65cd9c939f44485a104c63468e33964e13102ea16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page