tzdata
tzdata is a data-only Python package containing zic-compiled binaries for the IANA time zone database, maintained by the CPython core developers. It serves as a cross-platform fallback for the standard library's zoneinfo module (Python 3.9+, PEP 615) on systems that lack system-level zone data — most critically Windows. The current version is 2025.3 (wrapping upstream IANA tzdata 2025c). Releases track IANA upstream closely, typically producing between 3 and 10+ releases per year in response to real-world timezone rule changes.
Warnings
- breaking On Windows and minimal Linux containers (e.g. python:3.x-slim, Alpine without tzdata OS package), ZoneInfo raises ZoneInfoNotFoundError for every key if tzdata is not installed. The stdlib zoneinfo module itself does not bundle any data.
- gotcha On Linux/macOS, zoneinfo silently prefers system-level /usr/share/zoneinfo over the installed tzdata package. A stale or outdated system tzdata can shadow a freshly pip-installed tzdata, causing subtle DST/offset divergence between platforms.
- gotcha Pinning tzdata to a specific version (e.g. tzdata==2024.1) means your application will use stale timezone rules. IANA releases corrections multiple times per year, sometimes affecting future timestamps with very little notice.
- breaking ZoneInfo objects created via ZoneInfo.from_file() (no key set) cannot be pickled. Pickling ZoneInfo objects that were sourced from tzdata requires the same tzdata version to be present on the deserializing host; unpickling against a different version gives no error but may silently produce incorrect offsets.
- gotcha import tzdata itself does nothing useful for end users — the package exposes no callable API. Common mistake is calling tzdata() or tzdata.create() as if it were a factory, which raises AttributeError.
- gotcha zoneinfo.available_timezones() scans all sources on TZPATH plus tzdata; on systems with both system data and tzdata installed, the returned set reflects the union and count may vary across platforms, making set equality assertions in tests fragile.
- deprecated The importlib.resources.open_binary() API used in the official tzdata docs for library authors is deprecated in Python 3.11 in favour of importlib.resources.files().
Install
-
pip install tzdata -
uv add tzdata
Imports
- ZoneInfo
from zoneinfo import ZoneInfo # stdlib (Python 3.9+); tzdata is consumed automatically as a fallback
- IANA_VERSION
import tzdata; print(tzdata.IANA_VERSION)
- open_binary (library authors only)
from importlib import resources with resources.open_binary('tzdata.zoneinfo.America', 'New_York') as f: data = f.read()
Quickstart
# tzdata acts as a silent fallback — no explicit import required for end users.
# Install tzdata, then use zoneinfo normally:
from datetime import datetime
from zoneinfo import ZoneInfo
# Works on all platforms (including Windows) once tzdata is installed
dt_ny = datetime.now(ZoneInfo('America/New_York'))
dt_utc = datetime.now(ZoneInfo('UTC'))
print(f'New York : {dt_ny}')
print(f'UTC : {dt_utc}')
# Check which IANA version is bundled
import tzdata
print(f'IANA tzdata version: {tzdata.IANA_VERSION}')
# Verify tzdata is active as the data source (useful on Windows / minimal containers)
from zoneinfo import available_timezones
print(f'Available zones: {len(available_timezones())}')