Install & Compatibility
Where this runs
tested against v2.1.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.910 runs
installs and imports cleanly · install 0.0s · import 0.051s · 20.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.7s · import 0.055s · 21MB
19MB installed
● package 19MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
XMPFiles
✓ from libxmp import XMPFiles
✗ from xmp_toolkit import XMPFiles
The primary module name changed from `xmp_toolkit` to `libxmp` in version 2.0.0.
XMPMeta
✓ from libxmp import XMPMeta
✗ from xmp_toolkit import XMPMeta
The primary module name changed from `xmp_toolkit` to `libxmp` in version 2.0.0.
consts
✓ from libxmp import consts
✗ from xmp_toolkit import XMPConsts
The constants object was renamed from `XMPConsts` to `consts` and moved to the `libxmp` module in version 2.0.0.
This quickstart demonstrates how to create, manipulate, and serialize XMP metadata using the `XMPMeta` class, which handles XMP data in memory. It covers setting properties, adding array items, retrieving values, and converting the XMP object to an RDF/XML string.
from libxmp import XMPMeta, consts
# Create a new XMP metadata object
xmp = XMPMeta()
# Set properties in the Dublin Core namespace
xmp.set_property(consts.NS_DC, "title", "My Awesome Photo")
xmp.set_property(consts.NS_DC, "creator", "Jane Doe")
# Add items to an array property (e.g., keywords)
xmp.append_array_item(consts.NS_DC, "subject", "landscape", None, consts.XMP_ARRAY_LAST_ITEM)
xmp.append_array_item(consts.NS_DC, "subject", "mountains", None, consts.XMP_ARRAY_LAST_ITEM)
# Get a property
title = xmp.get_property(consts.NS_DC, "title")
print(f"Title: {title}")
# Iterate over array items
print("Subjects:")
for i in range(xmp.count_array_items(consts.NS_DC, "subject")):
# Array items are 1-indexed in XMP
item = xmp.get_array_item(consts.NS_DC, "subject", i + 1)
print(f"- {item}")
# Serialize XMP to RDF/XML string
rdf_string = xmp.dump_as_rdf()
print("\n--- XMP as RDF ---")
print(rdf_string)
print("------------------")
Errors
Common errors & fixes
ImportError: cannot import name 'XMPFiles' from 'xmp_toolkit'
Attempting to import from the old `xmp_toolkit` module after upgrading to version 2.0.0 or later.
fixChange your import statements from `from xmp_toolkit import ...` to `from libxmp import ...`.
libxmp.exempi.ExempiError: Exempi library not found.
The underlying C++ Exempi library is not installed or not discoverable in your system's library paths.
fixInstall Exempi on your system. For Debian/Ubuntu: `sudo apt-get install libexempi-dev`. For macOS (Homebrew): `brew install exempi`. Ensure your system's dynamic linker can find the library.
libxmp.exempi.ExempiError: Could not open file (no such file or directory)
The file specified for `XMPFiles` does not exist, or the provided path is incorrect, or there are insufficient permissions to access it.
fixVerify the file path is correct and the file exists. Check file permissions for read/write access depending on your operation. Use absolute paths where possible.
Upgrade
Version history
2.1.0latest on PyPI · released Nov 26, 2025
Audit
Dependencies
libexempirequiredThe underlying C++ library for XMP manipulation. Must be installed on the system (e.g., `sudo apt-get install libexempi` or `sudo apt-get install libexempi-dev` on Debian/Ubuntu, `brew install exempi` on macOS).