Registry / data / pint
library0.25.3pypypi✓ verified 23d ago

Pint is a Python package designed for defining, operating, and manipulating physical quantities. It allows for arithmetic operations between numerical values and units of measurement, as well as conversions between different units. The library includes a comprehensive list of physical units, prefixes, and constants, and its modular design enables users to extend or rewrite unit definitions. It integrates well with numerical libraries like NumPy and Pandas (via `pint-pandas`) and is actively maintained, with the latest stable version 0.25.3 released on March 19, 2026.

pip install pint
INSTALL
IMPORT
SIG · PINT
P
pint
datapythonv0.25.3
Install
2.0s avg
Import
442ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.24.4 · 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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.460s · 21.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.424s · 22MB
20MB installed
● package 20MB
Code
Verified usage

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

UnitRegistry
from pint import UnitRegistry

Initialize a `UnitRegistry` to define and manage units. Use the registry to create `Quantity` objects, perform arithmetic operations, and convert units. Pint automatically handles dimensional analysis during calculations.

from pint import UnitRegistry # Initialize the UnitRegistry, which stores unit definitions and handles conversions ureg = UnitRegistry() # Define quantities using numerical values and units from the registry distance = 24.0 * ureg.meter time = 8.0 * ureg.second # Perform calculations; Pint automatically handles unit propagation speed = distance / time print(f"Calculated Speed: {speed}") # Convert quantities to different compatible units speed_kmh = speed.to(ureg.kilometer / ureg.hour) print(f"Speed in kilometers per hour: {speed_kmh}") # Quantities can also be created by parsing strings force = ureg.Quantity("100 N") print(f"Force from string: {force}")
Debug
Known issues
breakingMinimum Python version support has increased over time. For Pint v0.25.3, Python 3.11+ is required. Older versions like 0.18 required Python 3.8+ and Numpy 1.19+; version 0.10 required Python 3.6+. Check the changelog for specific version compatibility.
fix
Ensure your Python environment meets the minimum version requirement for your chosen Pint release (e.g., Python >=3.11 for 0.25.3) and update NumPy if necessary.
affects: >=0.10
gotchaCreating multiple instances of `UnitRegistry` across different modules in your project can lead to `ValueError: Cannot operate with Quantity and Quantity of different registries.` when performing operations between them.
fix
Instantiate the `UnitRegistry` in a single, central location (e.g., your package's `__init__.py` file) and import that shared instance across your project. Optionally, use `set_application_registry(ureg)` for advanced scenarios.
affects: All
breakingAttempting to cast a `Quantity` with offset units (e.g., temperature in Celsius) to a boolean value will raise a `ValueError` since version 0.10. This prevents ambiguous boolean evaluations.
fix
Explicitly compare the quantity's magnitude to a reference value (e.g., `if temp.magnitude > 0:`) rather than relying on implicit boolean conversion.
affects: >=0.10
gotchaThe `auto_reduce_dimensions` and `autoconvert_to_preferred` parameters of `UnitRegistry` are `False` by default for performance reasons. This means units might not automatically simplify or convert to preferred forms unless explicitly enabled.
fix
If automatic simplification or conversion is desired, initialize your `UnitRegistry` with `ureg = UnitRegistry(auto_reduce_dimensions=True, autoconvert_to_preferred=True)` or call `.to_reduced_units()` / `.to_preferred()` explicitly.
affects: All
gotchaThere is a separate Python library for pulsar timing called `PINT` (all uppercase). Be careful not to confuse `pint` (lowercase, for physical quantities) with `PINT` when installing or searching, as they are distinct projects.
fix
Ensure you are installing `pint` (lowercase) for physical quantities and refer to its specific documentation and examples to avoid conflicts or incorrect usage.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pint'
The 'pint' package is not installed in the Python environment you are using.
fix
Install the pint library using pip: `pip install pint` or `pip3 install pint`.
pint.errors.UndefinedUnitError: 'foobar' is not defined in the unit registry.
You are trying to use a unit name or symbol ('foobar' in this example) that has not been defined or recognized by the active UnitRegistry instance.
fix
Ensure the unit name is spelled correctly, exists in Pint's default definitions, or define a custom unit if it's not standard. Example: `ureg.define('foobar = 10 meter')` or check for typos like `ureg.metre` instead of `ureg.meter`.
pint.errors.DimensionalityError: Cannot convert from 'meter' ([length]) to 'second' ([time])
You are attempting to perform a conversion or operation between quantities that have incompatible physical dimensions (e.g., length and time).
fix
Review the units of the quantities involved in the operation. Ensure that units being converted or operated upon belong to the same base dimension, or that the operation itself results in a dimensionally consistent quantity. For example, to convert from meters to feet: `(10 * ureg.meter).to(ureg.foot)`.
pint.errors.OffsetUnitCalculusError: Ambiguous operation with offset unit (degC, kelvin).
This error occurs when performing arithmetic operations (like addition) with quantities that involve offset units, such as Celsius or Fahrenheit temperatures, because the interpretation of such operations can be ambiguous.
fix
Convert quantities to a common absolute temperature unit (like Kelvin) before performing the ambiguous operation, or explicitly convert one of the offset units to a delta unit if the intent is to represent a temperature difference. Alternatively, set `ureg.autoconvert_offset_to_baseunit = True` for relaxed behavior, but be aware of potential ambiguities.
ValueError: Cannot operate with Quantity and Quantity of different registries.
You are trying to perform an operation between two Pint Quantity objects that were created using different UnitRegistry instances, which Pint explicitly prevents to avoid inconsistencies.
fix
Ensure all Quantity objects in your application are created from a single, globally accessible UnitRegistry instance. A common pattern is to initialize the registry once and import it where needed: `from pint import UnitRegistry; ureg = UnitRegistry()` in a central module, then `from . import ureg` elsewhere.
Upgrade
Version history
0.25.3latest on PyPI · released Mar 19, 2026
Audit
Dependencies
numpyoptionalOptional: enhanced support for array operations and ufuncs with quantities.
pandasoptionalOptional: integration for unit-aware DataFrames via the `pint-pandas` package.
uncertaintiesoptionalOptional: transparently handles calculations with quantities that have uncertainties.
babeloptionalOptional: enables unit name translation.
Agent activity
13 hits · last 30 days
node
12
Resources
pint — pip install pint · libregistry