pyStrich¶
pyStrich is a Python module for generating 1D and 2D barcodes. It supports
Code 39, Code 128, EAN-13, Data Matrix, QR Code, PDF417 and Aztec Code
symbologies. All seven emit PNG (via Pillow),
SVG and EPS. The 2D formats additionally render to terminal art and DXF
for direct part marking.
pyStrich is encoder-only – it does not read barcodes.
Installation¶
$ pip install pyStrich
Quick start¶
from pystrich.datamatrix import DataMatrixData, DataMatrixEncoder
payload = DataMatrixData("https://github.com/mmulqueen/pyStrich", auto_encoding=True)
DataMatrixEncoder(payload).save_svg("datamatrix-example.svg")
A minimal example for each of the other symbologies:
from pystrich.code39 import Code39Encoder
Code39Encoder("64755").save_svg("code39-example.svg")
from pystrich.code128 import Code128Encoder
Code128Encoder("WDBCA45D2HA327260").save_svg("code128-example.svg")
from pystrich.ean13 import EAN13Encoder
EAN13Encoder("5050070007664").save_svg("ean13-example.svg")
from pystrich.qrcode import QRCodeEncoder
QRCodeEncoder("https://github.com/mmulqueen/pyStrich").save_svg("qrcode-example.svg")
from pystrich.pdf417 import PDF417Encoder
PDF417Encoder("WDBCA45D2HA327260").save_svg("pdf417-example.svg")
from pystrich.aztec import AztecEncoder
AztecEncoder("https://github.com/mmulqueen/pyStrich").save_svg("aztec-example.svg")
For more patterns – serving barcodes from a web request, generating in bulk, compositing onto a label – see Recipes.
Symbologies¶
Guides¶
Reference¶
Background¶
pyStrich was originally a fork of huBarcode. huBarcode was developed by HuDoRa from at least 2007, and has not been active since late 2013. Method B Ltd forked huBarcode as pyStrich to provide Python 3 support and to continue development. pyStrich has been substantially enhanced over the years and has gone far beyond a simple port to Python 3. As of 2026, pyStrich is a modern Python package with full use of typing, linting and a comprehensive test suite.
Thanks to the folks at HuDoRa for the original huBarcode library that pyStrich grew out of.
Licence¶
If you worry about copyright you might consider this Software BSD-Licensed.
If you are still worried, you might consider it GPL1/2/3 compatible.
But don't worry. If you need something formal:
The code is available under the Apache License, Version 2.0.
Boilerplate for Apache License 2.0:
Copyright various contributors to huBarcode, later pyStrich.
Main contributions are from HuDoRa from at least 2007 to 2013
Contributions since 2015 are from Method B Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Courier Prime (used to generate the glyph outlines embedded in
pystrich/_courier_glyphs.py for SVG/EPS labels) is distributed under the
SIL Open Font License, Version 1.1. The upstream license text is bundled
inline as the OFL_LICENSE constant in pystrich/_courier_glyphs.py and is
also available at courier_prime/OFL.txt in the source repository.