Install & Compatibility
Where this runs
tested against v3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.296s · 42MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.0s · import 1.198s · 44MB
44MB installed
● package 44MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Usb
✓ from escpos.printer import Usb
✗ from escpos import Usb
Old import path from v2.x; v3.x requires full path from submodule
Serial
✓ from escpos.printer import Serial
✗ from escpos import Serial
Same as above
Network
✓ from escpos.printer import Network
✗ from escpos import Network
Same as above
File
✓ from escpos.printer import File
✗ from escpos import File
Same as above
Basic usage: open USB printer, print text, image, barcode, and cut paper.
from escpos.printer import Usb
# Replace with your printer's USB vendor and product IDs
p = Usb(0x04b8, 0x0202, in_ep=0x82, out_ep=0x01)
p.text("Hello World\n")
p.image("logo.png")
p.barcode("1234567890128", "EAN13", height=100)
p.cut()
Errors
Common errors & fixes
ValueError: Invalid barcode: '1234567890128' (EAN13) must be 12 or 13 digits.
Barcode data length or checksum incorrect. EAN13 requires 13 digits (or 12 with automatic checksum).
fixEnsure the barcode data is the correct length. For EAN13, provide 12 or 13 numeric digits.
escpos.exceptions.SetVariableError: Set variable failed for 'some_command'
Printer does not support the given command (capability issue).
fixCheck your printer's capabilities and use a different command or update capabilities file.
Audit
Dependencies
pyusboptionalUSB printer support (optional, only if using USB backend)
pyserialoptionalSerial printer support (optional, only if using serial backend)
python-barcodeoptionalBarcode generation (optional, only if using software barcodes)
PillowoptionalImage handling (optional, for image printing)