skillfed

ucumvert

Python parser & interface for UCUM (Unified Code for Units of Measure).

ucumvert v0.3.2 120.5K downloads/30d#12,023 on PyPI15
Permissive license MIT Active released

What it is and what it does

ucumvert bridges UCUM (Unified Code for Units of Measure) and Python's pint library. UCUM is a standardized code system for expressing units unambiguously in electronic communication; ucumvert provides a full parser for UCUM syntax and a converter that turns UCUM codes into pint Quantity objects. It includes a custom pint UnitRegistry pre-loaded with all UCUM unit definitions from specification version 2.2, so you can work with UCUM codes directly in pint without manual setup.

The parser is built on lark and generated from the official UCUM specification file (ucum-essence.xml), making it straightforward to update for new UCUM releases. The package handles the fact that some UCUM unit atoms are invalid in pint by maintaining explicit mappings (e.g., cal_[15] → cal_15). It is actively maintained and supports Python 3.11 through 3.14, though it remains in Beta and the maintainer recommends reviewing definitions and test coverage before production use.

Use it for:

  • Parse and convert UCUM unit codes in scientific or medical data pipelines where units must be unambiguous and standardized.
  • Build a pint-based unit conversion system that needs to handle UCUM notation from external data sources or standards.
  • Validate UCUM unit strings and convert them to pint quantities for dimensional analysis in research or engineering applications.
  • Extend pint's default unit definitions with the full UCUM catalog for domains that require comprehensive unit coverage.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses UCUM (Unified Code for Units of Measure) unit strings and converts them to pint-compatible units, with a built-in pint registry that includes all UCUM unit definitions.

Yes, if you work with UCUM unit codes and need to convert them to pint. The package is actively maintained, has low install friction, and includes comprehensive UCUM definitions. However, it is in Beta status—the maintainer explicitly warns that bugs may be present and recommends reviewing definitions before production use. Not necessary if you only use standard pint units.

Install

ucumvert on PyPI

pip

pip install ucumvert

uv

uv add ucumvert

poetry

poetry add ucumvert

Installing ucumvert

Before you install

Low friction install with only two runtime dependencies (lark and pint). Actively maintained with a recent release; however, the package is in Beta status and the maintainer explicitly notes that bugs may still be present and recommends reviewing definitions before trusting them in production.

License in practice

MIT license with a permissive treatment. Code in the repository is MIT-licensed except for ucum-*.* files in src/ucumvert/vendor, which fall under the UCUM Copyright Notice and License; the maintainer clarifies this is not considered derivative work under §1.3 of that license.

Quickstart

pip install ucumvert

from ucumvert import PintUcumRegistry
ureg = PintUcumRegistry()
result = ureg.from_ucum("m/s2.kg")
print(result)  # <Quantity(1.0, 'kilogram * meter / second ** 2')>

Requires Python 3.11 or later.

Verify before relying

  • Whether the UCUM-to-pint conversion covers all real-world UCUM codes used in your domain, given the note that only conversion from UCUM to pint is currently supported.
  • Performance characteristics when parsing or converting large volumes of UCUM codes.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 2 — lark, pint
Maintenance actively maintained — 71 days since the last release
Last repo commit
First released
Downloads 120,451/month — #12,023 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: ucumvert-0.3.2-py3-none-any.whl

Keywords: UCUM, parser, units of measurement

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

UCUM unit parserconvert UCUM to pintunits of measure parsingUCUM code converterscientific unit handlingunit string parser
unit-conversionscientific-computing

More Scientific/Engineering packages