Open Barcode for Python
A typed package built with a standard pyproject.toml and a unittest suite. No third-party imports.
Install
pip install openbarcodeGenerate a barcode
from openbarcode.linear import UPC
bars = UPC("03600029145").barcode() # 95 modulesThe example encodes UPC-A 03600029145, which gets check digit 2 and produces 95 modules. The same input gives the same modules in every Open Barcode library.
More examples
Each example uses the same modules as the tests, so the output matches the other languages.
from openbarcode.linear import UPC, EAN, Code39
upc = UPC("03600029145").barcode() # 95 modules
ean = EAN("400638133393").barcode() # 95 modules
code39 = Code39("CODE39").barcode() # 103 modulesfrom openbarcode.linear import UPC
try:
UPC("036000291453") # the check digit should be 2
except ValueError as err:
print(err)Source and tests
The source, tests and release workflow are in the Python repository on GitHub.