Unable to Start Home Assistant on Ubuntu 20.04

Hey All,

Hoping someone can help me here. I’ve been running Home Assistant for a number of years, using a basic python install (pip3 install homeassistant) on Ubuntu 20.04 and have just recently found I can no longer start the service. Version of Home Assistant is 2021.12.10, which is the latest version supported by the version of Python that ships with Ubuntu 20.04.

When I attempt to start HASS using /usr/local/bin/hass -c /opt/hass --open-ui I get the following:

2023-02-18 11:53:28 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/util/package.py", line 38, in is_installed
    pkg_resources.get_distribution(package)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 514, in get_distribution
    dist = get_provider(dist)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 386, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 956, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 815, in resolve
    dist = self._resolve_dist(
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 844, in _resolve_dist
    env = Environment(self.entries)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 1044, in __init__
    self.scan(search_path)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 1077, in scan
    self.add(dist)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 1096, in add
    dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 2631, in hashcmp
    self.parsed_version,
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 2678, in parsed_version
    self._parsed_version = parse_version(self.version)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/_vendor/packaging/version.py", line 266, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: '0.23ubuntu1'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/hass", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/__main__.py", line 318, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/runner.py", line 121, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/runner.py", line 103, in setup_and_run_hass
    hass = await bootstrap.async_setup_hass(runtime_config)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/bootstrap.py", line 131, in async_setup_hass
    await async_from_config_dict(config_dict, hass) is not None
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/bootstrap.py", line 230, in async_from_config_dict
    await conf_util.async_process_ha_core_config(hass, core_config)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/config.py", line 524, in async_process_ha_core_config
    hass, "auth", await auth.auth_manager_from_config(hass, auth_conf, mfa_conf)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/auth/__init__.py", line 64, in auth_manager_from_config
    modules = await asyncio.gather(
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/auth/mfa_modules/__init__.py", line 133, in auth_mfa_module_from_config
    module = await _load_mfa_module(hass, module_name)
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/auth/mfa_modules/__init__.py", line 170, in _load_mfa_module
    await requirements.async_process_requirements(
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/requirements.py", line 164, in async_process_requirements
    await _async_process_requirements(
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/requirements.py", line 184, in _async_process_requirements
    if pkg_util.is_installed(req):
  File "/usr/local/lib/python3.8/dist-packages/homeassistant/util/package.py", line 45, in is_installed
    req = pkg_resources.Requirement.parse(urlparse(package).fragment)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 3129, in parse
    (req,) = parse_requirements(s)
ValueError: not enough values to unpack (expected 1, got 0)

It appears to be complaining about the version that is installed, which it identifies as 0.23ubuntu1. Is there any recourse to recover here, or am I going to be stuck building a new server and trying to migrate my configs over to it?

Ubuntu is not a compatible OS. You have three choices-

  1. Install a Virtual OS (Debian)
  2. Install Debian
  3. Install the X-86 image of Home Assistant OS.

I am certain that there are at least a dozen other ways to install Home Assistant. For myself I am running the X-86 image of HAOS on an Intel NUC. That is all that is running on this NUC. It is easy to install and manage and you don’t have to mess with managing virtual machines or dockers.

Thanks for the reply, It seems odd that it would work for two years without issue and then today it fails to start. Wondering if something has changed with the update check the system does on startup or something?

Home Assistant requires python 3.10 from the latest release. You are running 3.8 so you need to upgrade or run Home Assistant using docker.