Registry / devops / pycups

pycups

JSON →
library2.0.4pypypiunverified

PyCUPS provides Python bindings for libcups, the Common Unix Printing System library. It allows Python applications to interact with CUPS servers to manage printers, print jobs, and monitor printer status. The current version is 2.0.4, with releases primarily focusing on bug fixes and compatibility with newer Python versions, rather than new features.

pip install pycups
INSTALL
IMPORT
SIG · PYCUPS
P
pycups
devopspythonv2.0.4
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
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.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cups
import cups

This quickstart demonstrates how to establish a connection to the local CUPS server and list all configured printers. It's a common first step to verify PyCUPS installation and CUPS server connectivity.

import cups # Connect to the local CUPS server conn = cups.Connection() # List all available printers printers = conn.getPrinters() if printers: print("Available Printers:") for printer_name, printer_attrs in printers.items(): print(f" - {printer_name}") # print(f" Location: {printer_attrs.get('printer-location')}") # print(f" State: {printer_attrs.get('printer-state-message')}") else: print("No printers found or CUPS server is not accessible.") # Example: Get default printer (if set) default_printer = conn.getDefault() # Returns string or None if default_printer: print(f"\nDefault Printer: {default_printer}")
Debug
Known issues
gotchaPyCUPS requires system-level CUPS development headers (e.g., `libcups2-dev` on Debian/Ubuntu, `cups-devel` on Fedora/RHEL) to be installed on the system *before* `pip install pycups`. Without these, the installation will fail with compilation errors.
fix
Install the necessary CUPS development package for your operating system (e.g., `sudo apt-get install libcups2-dev` or `sudo dnf install cups-devel`).
affects: All versions
gotchaMany functions in PyCUPS interact directly with the CUPS server. If the CUPS service is not running or accessible, operations like `cups.Connection()` or `conn.getPrinters()` will raise `cups.IPPError`.
fix
Ensure the CUPS service is running on your system (e.g., `sudo systemctl status cups` on systemd-based Linux distributions) and that appropriate firewall rules allow access if connecting remotely.
affects: All versions
gotchaWhen handling IPP attributes (like printer names, job titles) with non-ASCII characters, be mindful of encoding. While PyCUPS aims to handle UTF-8, explicit encoding/decoding may be necessary for certain operations or when integrating with other systems.
fix
Ensure all strings passed to PyCUPS functions are correctly encoded, typically to UTF-8. Decode received byte strings from CUPS if you encounter `UnicodeDecodeError` or unexpected characters.
affects: All versions
Upgrade
Version history
2.0.4latest on PyPI · released Apr 18, 2024
Audit
Dependencies
libcups-devrequiredRequires development headers for the CUPS library (e.g., `libcups2-dev` on Debian/Ubuntu, `cups-devel` on Fedora/RHEL) to compile the C extensions during installation.
Agent activity
6 hits · last 30 days
node
6
Resources
pycups — pip install pycups · libregistry