To generate SVG barcodes, use a barcode class (like EAN13) and provide an SVGWriter. You can write the output to a file-like object (e.g., BytesIO) or directly to a file.
Checksums are calculated automatically. For systems like Code 39 where checksums are optional, you can pass add_checksum=False as a keyword argument.
from io import BytesIO
from barcode import EAN13
from barcode.writer import SVGWriter
# Write to a file-like object:
rv = BytesIO()
EAN13("100000902922", writer=SVGWriter()).write(rv)
# Or to an actual file:
with open("somefile.svg", "wb") as f:
EAN13(str(100000011111), writer=SVGWriter()).write(f)