Registry / communication / python-escpos

python-escpos

JSON →
library3.1pypypi✓ verified 86d ago

Library to manipulate ESC/POS printers. Supports USB, serial, network, and file interfaces. Current version is 3.1 (released 2024-04-07). Requires Python >=3.8.

pip install python-escpos
INSTALL
IMPORT
SIG · PYTHON-ESCPOS
P
python-escpos
communicationpythonv3.1
Install
3.0s avg
Import
1247ms
Disk
44MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.296s · 42MB
glibc
py 3.103.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()
Debug
Known issues
breakingPython 2 support dropped in v3.0. Code relying on Python 2 will break.
fix
Upgrade to Python >=3.8.
affects: >=3.0
breakingImport paths changed in v3.0. Printer classes moved to `escpos.printer` submodule. Old imports like `from escpos import Usb` no longer work.
fix
Use `from escpos.printer import Usb` (and similarly for Serial, Network, File).
affects: >=3.0
breaking`escpos.escpos.Escpos` base class no longer directly importable. The API for creating printer instances changed.
fix
Use the specific printer class from `escpos.printer`.
affects: >=3.0
gotchaUSB printer requires `pyusb` and often root/sudo permissions on Linux. Without proper permissions, `Usb` initialization will fail with USBError.
fix
Set up udev rules for your printer or run as root.
affects: *
gotchaCapabilities file must be present for the library to know printer features. If missing, printing may produce garbage or no output.
fix
Ensure `python-escpos` is installed correctly; the capabilities are bundled. Alternatively, load a custom capabilities file.
affects: >=3.0
deprecated`escpos.escpos.Escpos.image()` method's parameters changed: `impl` parameter is deprecated in favor of `high_density`.
fix
Use `high_density=True` instead of `impl='bitImageColumn'`.
affects: >=3.0
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).
fix
Ensure 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).
fix
Check your printer's capabilities and use a different command or update capabilities file.
Upgrade
Version history
3.1latest on PyPI
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)
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources