Install & Compatibility
Where this runs
tested against v0.6.3 · 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 1.408s · 33.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.5s · import 1.334s · 33MB
31MB installed
● package 31MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
OME
✓ from ome_types import OME
Image
✓ from ome_types.model import Image
Pixels
✓ from ome_types.model import Pixels
OME as model
✓ from ome_types.model import OME
✗ from ome_types import OME (this is also correct for the top-level OME, but if you want the model specifically use the model submodule)
Both imports work for OME, but model submodule is explicit for internal model classes.
Create an OME object programmatically with required fields and serialize to XML.
from ome_types import OME
from ome_types.model import Image, Pixels
# Create minimal OME object
ome = OME(images=[Image(id='Image:0', name='test', pixels=Pixels(id='Pixels:0', dimension_order='XYZCT', size_x=10, size_y=10, size_c=1, size_z=1, size_t=1, type='uint8'))])
print(ome.to_xml())
Errors
Common errors & fixes
pydantic_core._pydantic_core.ValidationError: 1 validation error for OME
Missing required field when constructing OME or model objects.
fixCheck all required fields in the OME schema. For OME object, images is required (list of Image). For Image, id and name are required. For Pixels, id, dimension_order, size_x, size_y, size_c, size_z, size_t, type are required.
ModuleNotFoundError: No module named 'ome_types.model.OME'
Trying to import OME from wrong submodule; in older versions OME was in ome_types.model, newer versions it is in ome_types directly.
fixUse 'from ome_types import OME' (top-level import) for current versions (>=0.6.0).
AttributeError: 'dict' object has no attribute 'to_xml'
Calling to_xml() on a dict instead of an OME model instance, often happens when using .model_dump() incorrectly.
fixEnsure you have an OME object, not a dict. Use .model_dump(mode='python') to get dict representation, but to_xml() is only on the model object.
Upgrade
Version history
0.6.3latest on PyPI · released Nov 26, 2025
Audit
Dependencies
pydanticrequiredome-types uses pydantic BaseModel for its dataclasses, required for validation and serialization.