Troubleshooting
This guide covers common problems and their solutions.
Connection Issues
“Printer not responding” (Network)
Symptoms:
PrinterTimeoutErrorexceptionNo response from printer
Solutions:
Verify printer is powered on and connected to network
ping 192.168.1.100
Check IP address is correct
Print network configuration from printer menu
Verify IP hasn’t changed (use static IP or DHCP reservation)
Check firewall settings
# Linux: Allow port 9100 sudo ufw allow 9100/tcp # Test with telnet telnet 192.168.1.100 9100
Try different network
Some networks block printer protocols
Corporate networks may require special configuration
Increase timeout
connection = ConnectionNetwork("192.168.1.100") printer = PTP900(connection) # After first connection, adjust timeout printer.print(first_label) if hasattr(connection, '_socket'): connection._socket.settimeout(30.0)
“Permission denied” (USB)
Symptoms:
PrinterPermissionErrorexceptionusb.core.USBError: [Errno 13] Access denied (insufficient permissions)
Solutions:
Configure USB permissions (recommended)
See Installation for detailed udev rules setup.
Run with sudo (not recommended)
sudo python your_script.py
“Printer not found” (USB)
Symptoms:
PrinterNotFoundErrorexceptionNo USB device found
Solutions:
Verify USB connection
lsusb | grep Brother # Should show: Bus 001 Device 010: ID 04f9:20af Brother Industries, Ltd
Check product ID matches
import usb.core # List all Brother devices devices = usb.core.find(find_all=True, idVendor=0x04f9) for dev in devices: print(f"Product ID: {hex(dev.idProduct)}") # Compare with printer class USB_PRODUCT_ID
Try different USB port
Some USB hubs cause issues
Try direct connection to computer
Check USB cable
Try a different cable
Some cables are power-only
Network Error After Print Start
Symptoms:
Print starts but fails mid-job
PrinterNetworkErrorduring printing
Solutions:
Check WiFi signal strength
Move printer closer to access point
Use Ethernet instead of WiFi
Implement retry logic
def print_with_retry(printer, label, max_retries=3): for attempt in range(max_retries): try: printer.print(label) return except PrinterNetworkError: if attempt == max_retries - 1: raise print(f"Retry {attempt + 1}/{max_retries}...") time.sleep(2)
Print Quality Issues
Misaligned Labels
Symptoms:
Content shifted up/down on tape
Cut-off text or images
Causes and Solutions:
Wrong tape type specified
# Wrong: Using 12mm tape but specified 24mm label = TextLabel("Text", Tape24mm, font=font) # Correct: Match actual tape in printer label = TextLabel("Text", Tape12mm, font=font)
Wrong printer class
# Wrong: PT-E550W connected but using PT-P900 class printer = PTP900(connection) # Wrong # Correct: Match actual printer model printer = PTE550W(connection) # Correct
Check tape is loaded correctly
Remove and reinsert tape cassette
Ensure tape feeds smoothly
Blurry or Pixelated Text
Symptoms:
Text appears jagged or blurry
Poor print quality
Solutions:
Enable high resolution mode
printer = PTP900(connection, high_resolution=True)
Use appropriate font size
Small text (< 12pt) benefits from high-res mode
Very large text may look pixelated - use vector fonts
Check image resolution
# Match printer DPI # P900: 360 DPI standard, 720 DPI high-res # E550W: 180 DPI standard, 360 DPI high-res def create_image_for_printer(width_mm, tape_mm, high_res=True): dpi = 720 if high_res else 360 width_px = int(width_mm * dpi / 25.4) height_px = int(tape_mm * dpi / 25.4) return Image.new("RGB", (width_px, height_px), "white")
Check print head
Clean print head following manual instructions
Run printer’s cleaning cycle
Incomplete Labels
Symptoms:
Label cuts off at the end
Missing content on right side
Solutions:
Check label width calculation
# For text labels, auto-sizing should work label = TextLabel("Text", Tape12mm, font=font) # Auto-sized # For image labels, ensure image isn't too wide max_width_mm = 100 # Adjust based on your needs width_px = int(max_width_mm * 360 / 25.4) # Resize if needed if img.width > width_px: aspect = img.height / img.width img = img.resize((width_px, int(width_px * aspect)))
Increase margin
printer.print(label, margin_mm=5.0)
Vertical Lines in Print
Symptoms:
White vertical lines in solid areas
Uneven print density
Causes:
Dirty print head
Worn print head
Solutions:
Run printer’s cleaning cycle (see manual)
Replace print head if worn (see manual)
Try different tape cassette to rule out tape issue
Software Issues
Import Errors
Symptoms:
ModuleNotFoundError: No module named 'ptouch'ImportError: cannot import name 'PTP900'
Solutions:
Verify installation
pip list | grep ptouch # Should show: ptouch 1.0.0 (or similar)
Reinstall package
pip uninstall ptouch pip install ptouch
Check Python version
python --version # Requires Python 3.11 or later
Virtual environment issues
# Ensure you're in the correct venv which python pip install ptouch
Font Errors
Symptoms:
OSError: cannot open resourceAttributeError: 'NoneType' object has no attribute 'getsize'
Solutions:
Use ImageFont.load_default()
from PIL import ImageFont # Simplest solution - always available font = ImageFont.load_default()
Verify font file path
import os font_path = "/path/to/font.ttf" if not os.path.exists(font_path): print(f"Font not found: {font_path}") # Use absolute paths font = ImageFont.truetype(os.path.abspath(font_path), 48)
Find system fonts
# Linux fc-list : file | grep -i dejavu # macOS ls /System/Library/Fonts/ ls ~/Library/Fonts/ # Windows dir C:\\Windows\\Fonts
Install fonts
# Debian/Ubuntu sudo apt install fonts-dejavu # Fedora/RHEL sudo dnf install dejavu-fonts
Command Line Issues
“ptouch: command not found”
Solutions:
Use python -m
python -m ptouch "Hello World" --host 192.168.1.100 \ --printer P900 --tape-width 36
Check installation
pip show ptouch # Look for "Location" line # Check if scripts directory is in PATH echo $PATH
Reinstall with –force-reinstall
pip install --force-reinstall ptouch
Wrong Arguments Error
Symptoms:
error: the following arguments are required
Solutions:
Check required arguments
ptouch --help # Required: --host or --usb, --printer, --tape-width # Required: text or --image
Common mistakes
# Wrong: Missing connection ptouch "Text" --printer P900 --tape-width 36 # Correct: ptouch "Text" --host 192.168.1.100 --printer P900 --tape-width 36 # Wrong: Missing text ptouch --host 192.168.1.100 --printer P900 --tape-width 36 # Correct: ptouch "Hello" --host 192.168.1.100 --printer P900 --tape-width 36
Performance Issues
Slow Printing
Causes and Solutions:
High resolution mode enabled
High-res doubles print time
Use standard resolution if quality permits
printer = PTP900(connection, high_resolution=False)
Large images
Resize images to required dimensions
Don’t use images larger than necessary
Network latency
Use USB instead of network if possible
Check network connection quality
Compression disabled
Enable compression (it’s on by default)
printer.print(label, use_compression=True)
Individual prints instead of batch
# Slow: Individual prints for text in texts: label = TextLabel(text, Tape12mm, font=font) printer.print(label) # Fast: Batch printing labels = [TextLabel(t, Tape12mm, font=font) for t in texts] printer.print_multi(labels)
Getting More Help
If you can’t solve your issue:
Check GitHub Issues
Search existing issues: https://github.com/nbuchwitz/ptouch/issues
Someone may have had the same problem
Enable Debug Logging
import logging logging.basicConfig(level=logging.DEBUG) # Now run your code - more verbose output
Create Minimal Example
Simplify your code to smallest example that reproduces the issue
Remove unrelated code
Use simple test data
File a Bug Report
Include:
Python version:
python --versionPackage version:
pip show ptouchOperating system
Printer model
Minimal code example
Complete error message with stack trace
What you’ve already tried
Create issue at: https://github.com/nbuchwitz/ptouch/issues/new
Check Documentation
Quick Start - Basic usage
User Guide - Common patterns
Advanced Topics - Performance optimization
Printer Module - API reference