Registry / data / pytzdata

pytzdata

JSON →
library2020.1pypypi✓ verified 27d ago

pytzdata is a Python library that provides access to the IANA/Olson timezone database files. It packages a snapshot of this database, allowing applications to retrieve raw timezone definitions. The current version, 2020.1, was released in July 2020. The project does not appear to follow a regular release cadence and is effectively in maintenance mode, largely superseded by the standard library `zoneinfo` module in Python 3.9+ and the `tzdata` package.

pip install pytzdata
INSTALL
IMPORT
SIG · PYTZDATA
P
pytzdata
datapythonv2020.1
Install
1.6s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2020.1 · 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.000s · 20.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 21MB
18MB installed
● package 18MB
Code
Verified usage

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

tz_file
from pytzdata import tz_file
from pytzdata import timezone
`timezone` is part of the `pytz` library, not `pytzdata`. `pytzdata` provides data files, not `tzinfo` objects.
tz_path
from pytzdata import tz_path
set_directory
import pytzdata pytzdata.set_directory('/custom/zoneinfo')
Used to point `pytzdata` to a custom directory containing timezone data files.

Demonstrates how to retrieve the file path for a timezone or access its raw content using `tz_path` and `tz_file`.

from pytzdata import tz_path # Get the path to a specific timezone file paris_tz_path = tz_path('Europe/Paris') print(f"Path to Europe/Paris timezone data: {paris_tz_path}") from pytzdata import tz_file # Access the content of a specific timezone file with tz_file('America/New_York') as f: content_start = f.read(50) print(f"First 50 bytes of America/New_York data: {content_start}...")
Debug
Known issues
deprecatedThe `pytzdata` package itself has not been updated since July 2020. For new projects on Python 3.9 and later, the standard library's `zoneinfo` module, typically combined with the `tzdata` PyPI package, is the recommended and more up-to-date solution for timezone handling.
fix
For Python 3.9+, use `from zoneinfo import ZoneInfo` and `pip install tzdata`. For older Python versions requiring external timezone libraries, consider `dateutil.tz` or pinning `pytzdata` and `pytz` to known working versions while being aware of potential data staleness.
affects: <=2020.1
gotchapytzdata only provides the raw IANA/Olson timezone *data files*. It does not provide `tzinfo` objects for direct use with Python's `datetime` module. Libraries like `pytz` (which historically used `pytzdata`'s format) or `zoneinfo` are required to create timezone-aware `datetime` objects.
fix
To create timezone-aware `datetime` objects, use `pytz.timezone('Europe/Paris')` (for `pytz`) or `ZoneInfo('Europe/Paris')` (for `zoneinfo` with Python 3.9+ and `tzdata` installed). Do not attempt to use `pytzdata` imports directly as `tzinfo` objects.
affects: all
gotchaDue to its last release being in 2020, the timezone data bundled with `pytzdata` (version 2020.1) may be outdated. IANA Time Zone Database rules are updated periodically, and `pytzdata` will not reflect these changes without a new release.
fix
Ensure your timezone data is current. If using Python 3.9+, prefer `zoneinfo` with `tzdata`, which is updated more frequently. If you must use `pytzdata`, be aware that recent changes to daylight saving rules or geopolitical timezone changes might not be reflected.
affects: 2020.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pytzdata'
The `pytzdata` library has not been installed in your current Python environment.
fix
pip install pytzdata
AttributeError: module 'pytzdata' has no attribute 'timezone'
You are attempting to use a method (`timezone`) that is part of the `pytz` library (or `zoneinfo` in Python 3.9+), not `pytzdata`. `pytzdata` provides the raw timezone data files, not direct timezone objects for `datetime` manipulation.
fix
To create timezone-aware `datetime` objects, use `pytz` (`import pytz; tz = pytz.timezone('Europe/London')`) or the standard library `zoneinfo` (`from zoneinfo import ZoneInfo; tz = ZoneInfo('Europe/London')`).
FileNotFoundError: [Errno 2] No such file or directory: '.../pytzdata/zones/Continent/NonExistentCity'
The requested timezone name either does not exist in the `pytzdata` database, is misspelled, or the internal path to the data files is incorrect.
fix
Verify the correct spelling of the timezone name (e.g., 'Europe/London'). You can use `pytzdata.get_all_timezones()` to list all available timezone names.
ModuleNotFoundError: No module named 'pytzdata.tzdata'
You are attempting to import `tzdata` as a submodule of `pytzdata`, which does not exist. This might stem from confusion with the separate `tzdata` package or how `pytz` organizes its data.
fix
To access `pytzdata` functionality, import the main `pytzdata` module directly (`import pytzdata`). If you intended to use the separate `tzdata` package, ensure it is installed (`pip install tzdata`) and import it as `import tzdata`.
Upgrade
Version history
2020.1latest on PyPI · released Jul 13, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
pytzdata — pip install pytzdata · libregistry