"Unable to set up dependencies of telegram" after upgrade to 108.3

After upgrading to 108.3, my Telegram component seems to have stopped working.
Logfile:

2020-04-13 11:00:04 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of telegram. Setup failed for dependencies: telegram_bot
2020-04-13 11:00:04 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform telegram.notify: Could not set up all dependencies.
2020-04-13 11:00:04 ERROR (MainThread) [homeassistant.components.notify] Unknown notification service specified
2020-04-13 13:40:54 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall script.manual_reboot (c:b3af184f0786481a8143401f38133a0a)>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1240, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1255, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 207, in service_handler
    await script.async_turn_on(variables=service.data, context=service.context)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 284, in async_turn_on
    await self.script.async_run(kwargs.get(ATTR_VARIABLES), context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 802, in async_run
    await run.async_run()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 523, in async_run
    await self._async_run()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 540, in _async_run
    await self._async_step(log_exceptions=not propagate_exceptions)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 154, in _async_step
    self, f"_async_{cv.determine_script_action(self._action)}_step"
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 624, in _async_call_service_step
    *self._prep_call_service_step(), blocking=True, context=self._context
  File "/usr/src/homeassistant/homeassistant/core.py", line 1207, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service notify/telegram

I use this component a lot but the above error originates from executing this script:

manual_reboot:
    sequence:
      - service: notify.telegram
        data:
          message: 'Manual reboot starting..' 
      - service: hassio.host_reboot

Config:

notify:
  - name: Telegram
    platform: telegram
    api_key: !secret telegram_api_key
    chat_id: !secret telegram_chat_id

I could not find any breaking changes on the Notify and/or Telegram component. Anyone else having issues?

My telegram is working fine on 108.3 :man_shrugging:

Ok this is weird. After restarting twice (again) everything is working as expected. Just a glitch during boot I guess (twice in a row).

Sorry for the false alarm :slight_smile:

1 Like

Again occurs when update to 2021.1.4 in the first boot.

Logger: homeassistant.setup
Source: components/telegram_bot/polling.py:6
First occurred: 17:28:43 (1 occurrences)
Last logged: 17:28:43
Error during setup of component telegram_bot

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2962, in _dep_map
    return self.__dep_map
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2756, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2953, in _parsed_pkg_info
    return self._pkg_info
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2756, in __getattr__
    raise AttributeError(attr)
AttributeError: _pkg_info

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/telegram_bot/__init__.py", line 307, in async_setup
    ".{}".format(p_config[CONF_PLATFORM]), __name__
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/telegram_bot/polling.py", line 6, in <module>
    from telegram.ext import CallbackContext, Dispatcher, Handler, Updater
  File "/srv/homeassistant/lib/python3.7/site-packages/telegram/ext/__init__.py", line 27, in <module>
    from .jobqueue import JobQueue, Job
  File "/srv/homeassistant/lib/python3.7/site-packages/telegram/ext/jobqueue.py", line 27, in <module>
    from apscheduler.events import EVENT_JOB_ERROR, EVENT_JOB_EXECUTED, JobEvent
  File "/srv/homeassistant/lib/python3.7/site-packages/apscheduler/__init__.py", line 4, in <module>
    release = get_distribution('APScheduler').version.split('-')[0]
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 481, in get_distribution
    dist = get_provider(dist)
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 357, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 794, in resolve
    new_requirements = dist.requires(req.extras)[::-1]
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2700, in requires
    dm = self._dep_map
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2964, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2973, in _compute_dependencies
    for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2955, in _parsed_pkg_info
    metadata = self.get_metadata(self.PKG_INFO)
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1412, in get_metadata
    value = self._get(self._fn(self.egg_info, name))
  File "/srv/homeassistant/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1587, in _get
    with open(path, 'rb') as stream:
FileNotFoundError: [Errno 2] No such file or directory: '/srv/homeassistant/lib/python3.7/site-packages/pytz-2020.4.dist-info/METADATA'

After a 2nd reboot RESTART, all is fine.

Reboot or restart?

They are different things.

  • Restart - restart the home assistant service.

  • Reboot - shut down the host machine and everything running on it and then start it up again.

RESTART, sorry. :slightly_smiling_face:

1 Like

I continue to see this same issue with the Telegram Integration… about every other HASS (v2021.3.x) restart, Telegram bot fails with the network connection error. I need to be aware to check notifications or logs to know if I need to restart HASS again to clear the critical Telegram error, which seems to always work.

So this is no false alarm, it’s apparently a timing issue that occurs with the Telegram initialization that occurs during HASS startup.

After two years of faultless Telegram notifier use, this has now started to happen to me too.

I have to restart twice for Telegram to be available.

I’ve just moved up a couple of versions to 2021.8.6 and I am also getting this. 2 restarts have not helped, but a reboot of the host has suppressed errors and telegram tested ok