Install & Compatibility
Where this runs
tested against v3.28.0 · 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 0.106s · 38.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.2s · import 0.104s · 39MB
36MB installed
● package 36MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
generate_barcode
✓ from treepoem import generate_barcode
ImageOps
✓ from PIL import ImageOps
Commonly used with treepoem for image manipulation, like adding borders.
This quickstart generates a QR code from a URL, adds a 10-pixel white border, and saves it as a monochrome PNG file named 'barcode.png'. The `ImageOps.expand` and `image.convert("1")` steps are common for preparing the output image.
import treepoem
from PIL import ImageOps
# Generate a QR code barcode
image = treepoem.generate_barcode(
barcode_type="qrcode",
data="https://www.example.com"
)
# Add a white border and save as a monochrome PNG
image = ImageOps.expand(image, border=10, fill="white")
image.convert("1").save("barcode.png")
print("Generated barcode.png")
Debug
Known issues
gotchaOlder Ghostscript versions (e.g., 9.22+) may produce smeared barcode images. While a fix was merged in Ghostscript 9.26, some smearing might still occur with certain barcodes.fixEnsure Ghostscript version 9.26 or newer is installed. Check your Ghostscript version with `gs --version`.
affects: Ghostscript < 9.26 (potential issues)
gotchatreepoem relies on an external Ghostscript installation, which is a non-Python dependency. This can complicate deployment in environments where installing system-level packages is restricted (e.g., some serverless functions, shared hosting).fixVerify that Ghostscript can be installed and is accessible in your target deployment environment. Consider containerization (e.g., Docker) to manage external dependencies.
affects: All versions
gotchaGenerating multiple barcodes in a tight loop can be slow because treepoem re-initializes and reopens the Ghostscript subprocess for each call to `generate_barcode()`.fixFor applications requiring high-volume barcode generation, explore alternatives that can keep the Ghostscript process alive or use a different rendering approach if performance is critical.
affects: All versions
Errors
Common errors & fixes
treepoem.errors.TreepoemError: Ghostscript not found. Please install it or make sure it is in your PATH.
Treepoem requires Ghostscript to be installed on the system and its executable path included in the system's PATH environment variable to render barcodes.
fixInstall Ghostscript from its official website (www.ghostscript.com) and ensure its `bin` directory is added to your system's PATH.
ModuleNotFoundError: No module named 'treepoem'
The `treepoem` library has not been installed in your current Python environment.
fixInstall the library using pip: `pip install treepoem`
treepoem.errors.TreepoemError: Unknown barcode type: 'qrcodes'. Available types: ['azteccode', 'azteccodecompact', ...]
The barcode type specified is either misspelled or not a recognized type supported by the `treepoem` library.
fixUse a valid barcode type from the list provided in the error message, such as 'qrcode' instead of 'qrcodes', or retrieve available types with `treepoem.get_barcode_types()`.
treepoem.errors.TreepoemError: BWIPP error: EAN13 must be 12 digits
The data provided for the barcode does not meet the specific length, format, or character set requirements of the chosen barcode type as enforced by the underlying BWIPP library.
fixEnsure the input data strictly conforms to the specifications of the selected barcode standard (e.g., EAN13 requires exactly 12 numeric digits for its data input).
FileNotFoundError: [Errno 2] No such file or directory: 'gs'
The Ghostscript command-line tool, a mandatory dependency for treepoem, is either not installed or not accessible in the system's PATH environment variable.
fixInstall Ghostscript on your system and ensure its executable (`gs` on Linux/macOS, `gswin64c.exe` on Windows) is added to the system's PATH, or specify its path directly using `treepoem.configure(ghostscript='/path/to/gs')`.
Upgrade
Version history
3.28.0latest on PyPI · released Sep 9, 2025
Audit
Dependencies
PillowrequiredRequired for outputting barcode images to various formats (e.g., PNG).
GhostscriptrequiredExternal command-line tool essential for rendering PostScript into images. Must be installed separately.