Skip to content

Raised error: 'No time zone found with key EST' #1531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
satish77 opened this issue Apr 28, 2025 · 6 comments
Closed

Raised error: 'No time zone found with key EST' #1531

satish77 opened this issue Apr 28, 2025 · 6 comments

Comments

@satish77
Copy link

Had to install python-kasa using pipx again after upgrading to Ubuntu 25.04 for some reason.

It was working fine with the previous version of Ubuntu.

The following stacktrace was found after running kasa. It did find three devices with no issues.

Raised error: 'No time zone found with key EST'
Traceback (most recent call last):
  File "/usr/lib/python3.13/zoneinfo/_common.py", line 12, in load_tzdata
    return resources.files(package_name).joinpath(resource_name).open("rb")
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/importlib/resources/_common.py", line 46, in wrapper
    return func(anchor)
  File "/usr/lib/python3.13/importlib/resources/_common.py", line 56, in files
    return from_package(resolve(anchor))
                        ~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/functools.py", line 934, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.13/importlib/resources/_common.py", line 82, in _
    return importlib.import_module(cand)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tzdata'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/satish/.local/bin/kasa", line 8, in <module>
    sys.exit(cli())
             ~~~^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/common.py", line 282, in __call__
    asyncio.run(self.main(*args, **kwargs))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/asyncclick/core.py", line 1126, in main
    rv = await self.invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/common.py", line 270, in invoke
    _handle_exception(self._debug, exc)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/common.py", line 268, in invoke
    return await super().invoke(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/asyncclick/core.py", line 1728, in invoke
    rv = await super().invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/asyncclick/core.py", line 1496, in invoke
    return await ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/asyncclick/core.py", line 829, in invoke
    rv = await rv
         ^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/main.py", line 301, in cli
    return await invoke_subcommand(discover, ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/common.py", line 114, in invoke_subcommand
    return await command.invoke(sub_ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/asyncclick/core.py", line 1728, in invoke
    rv = await super().invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/asyncclick/core.py", line 1496, in invoke
    return await ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/asyncclick/core.py", line 829, in invoke
    rv = await rv
         ^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/discover.py", line 41, in discover
    return await ctx.invoke(detail)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/asyncclick/core.py", line 829, in invoke
    rv = await rv
         ^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/discover.py", line 102, in detail
    discovered = await _discover(
                 ^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/discover.py", line 227, in _discover
    discovered_devices = await Discover.discover(
                         ^^^^^^^^^^^^^^^^^^^^^^^^
    ...<8 lines>...
    )
    ^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/discover.py", line 501, in discover
    await protocol.wait_for_discovery_to_complete()
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/discover.py", line 301, in wait_for_discovery_to_complete
    await asyncio.gather(*self.callback_tasks)
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cli/discover.py", line 89, in print_discovered
    await dev.update()
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/iot/iotdevice.py", line 326, in update
    await module._post_update_hook()
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/iot/modules/time.py", line 28, in _post_update_hook
    self._timezone = await get_timezone(res.get("index"))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/iot/iottimezone.py", line 24, in get_timezone
    return await CachedZoneInfo.get_cached_zone_info(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cachedzoneinfo.py", line 20, in get_cached_zone_info
    zinfo = await loop.run_in_executor(None, _get_zone_info, time_zone_str)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/satish/.local/pipx/venvs/python-kasa/lib/python3.13/site-packages/kasa/cachedzoneinfo.py", line 27, in _get_zone_info
    return ZoneInfo(time_zone_str)
  File "/usr/lib/python3.13/zoneinfo/_common.py", line 24, in load_tzdata
    raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key EST'
@ZeliardM
Copy link
Contributor

Install tzdata as well and that should resolve the problem.

@satish77
Copy link
Author

tzdata is already installed. kasa shows the same error.

~ sudo apt install tzdata
tzdata is already the newest version (2025b-1ubuntu1).
Summary:
Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0

@ZeliardM
Copy link
Contributor

@satish77 Is python-kasa using a venv? Not sure how pipx does things but if it's under a venv you'll need to install tzdata under the venv for python-kasa as it won't use the global install. The error you post explicitly states that it can't find the module tzdata.

@ZeliardM
Copy link
Contributor

Should be able to use:

pipx inject python-kasa tzdata

Then confirm with:

pipx runpip python-kasa list

@satish77
Copy link
Author

Pipx inject fixed it. Thanks. My script for powering on the laptop works now by looking up ip using kasa

@ZeliardM
Copy link
Contributor

@satish77 Great! Glad I could help! If you could close this out! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants