{"id":1022,"library":"pytzdata","title":"Olson Timezone Database for Python","description":"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.","status":"maintenance","version":"2020.1","language":"python","source_language":"en","source_url":"https://github.com/sdispater/pytzdata","tags":["timezone","iana","olson","tzdata","datetime","legacy"],"install":[{"cmd":"pip install pytzdata","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"`timezone` is part of the `pytz` library, not `pytzdata`. `pytzdata` provides data files, not `tzinfo` objects.","wrong":"from pytzdata import timezone","symbol":"tz_file","correct":"from pytzdata import tz_file"},{"symbol":"tz_path","correct":"from pytzdata import tz_path"},{"note":"Used to point `pytzdata` to a custom directory containing timezone data files.","symbol":"set_directory","correct":"import pytzdata\npytzdata.set_directory('/custom/zoneinfo')"}],"quickstart":{"code":"from pytzdata import tz_path\n\n# Get the path to a specific timezone file\nparis_tz_path = tz_path('Europe/Paris')\nprint(f\"Path to Europe/Paris timezone data: {paris_tz_path}\")\n\nfrom pytzdata import tz_file\n\n# Access the content of a specific timezone file\nwith tz_file('America/New_York') as f:\n    content_start = f.read(50)\n    print(f\"First 50 bytes of America/New_York data: {content_start}...\")","lang":"python","description":"Demonstrates how to retrieve the file path for a timezone or access its raw content using `tz_path` and `tz_file`."},"warnings":[{"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.","message":"The `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.","severity":"deprecated","affected_versions":"<=2020.1"},{"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.","message":"pytzdata 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.","severity":"gotcha","affected_versions":"all"},{"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.","message":"Due 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.","severity":"gotcha","affected_versions":"2020.1"}],"env_vars":null,"search_vec":"'2020':42 '2020.1':37 '3.9':70 'access':13 'allow':27 'appear':47 'applic':28 'cadenc':53 'current':35 'databas':3,18,26 'datetim':79 'definit':33 'effect':56 'file':19 'follow':49 'iana':76 'iana/olson':16 'juli':41 'larg':60 'legaci':80 'librari':10,65 'mainten':58 'mode':59 'modul':67 'olson':1,77 'packag':21,74 'project':44 'provid':12 'python':5,9,69 'pytzdata':6 'raw':31 'regular':51 'releas':39,52 'retriev':30 'snapshot':23 'standard':64 'supersed':61 'timezon':2,17,32,75 'tzdata':73,78 'version':36 'zoneinfo':66","created_at":"2026-03-29T08:39:11.399780+00:00","updated_at":"2026-04-16T20:34:50.579833+00:00","problems":[{"fix":"pip install pytzdata","cause":"The `pytzdata` library has not been installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'pytzdata'"},{"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')`).","cause":"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.","error":"AttributeError: module 'pytzdata' has no attribute 'timezone'"},{"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.","cause":"The requested timezone name either does not exist in the `pytzdata` database, is misspelled, or the internal path to the data files is incorrect.","error":"FileNotFoundError: [Errno 2] No such file or directory: '.../pytzdata/zones/Continent/NonExistentCity'"},{"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`.","cause":"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.","error":"ModuleNotFoundError: No module named 'pytzdata.tzdata'"}],"ecosystem":"pypi","meta_description":null,"install_score":80,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2020.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/sdispater/pytzdata","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytzdata/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}