cannot import name 'async_clear_install_history' after upgrading homeassistant from 2021.8.8 to 2021.11.3

Hi, I run homeassistant on a Raspberry Pi 4 with DietPi v7.8.2 and just updated homeassistant from 2021.8.8 to 2021.11.3 with the dietpi update script without any issues visible during the update process.

After the successful update, I tried to restart HA server, but it warned me:

Logger: homeassistant.components.websocket_api.http.connection
Source: helpers/check_config.py:27
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 20:43:52 (2 occurrences)
Last logged: 20:55:11

[547355522000] cannot import name 'async_clear_install_history' from 'homeassistant.requirements' (/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/requirements.py)
Traceback (most recent call last):
  File "/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/core.py", line 1491, in async_call
    _LOGGER.debug("Service was cancelled: %s", service_call)
  File "/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/core.py", line 1526, in _execute_service
    self, handler: Service, service_call: ServiceCall
  File "/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/helpers/service.py", line 728, in admin_handler
    if call.context.user_id:
  File "/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/components/homeassistant/__init__.py", line 148, in async_handle_core_service
    )
  File "/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/config.py", line 921, in async_check_ha_config_file
  File "/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/helpers/check_config.py", line 27, in <module>
    from homeassistant.requirements import (
ImportError: cannot import name 'async_clear_install_history' from 'homeassistant.requirements' (/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/requirements.py)

So now the system is running the old version and I am afraid it might not start up again after updating DietPi and restarting the HA service due to the error, and also I would be stuck with version 2021.8.8 :frowning:

I asked this yesterday at the community.home-assistant.io forum https://community.home-assistant.io/t/need-help-cannot-import-name-async-clear-install-history-after-update-to-2021-11-3/357056, but I thought this might also just be DietPi related and maybe anyone else here can confirm an un/successful HA update to 2021.11.3.

Some more info about HA I shared in the other thread as well:

If I check “/home/homeassistant/.pyenv/versions/3.8.10/lib/python3.8/site-packages/homeassistant/requirements.py” I find

@callback
def async_clear_install_history(hass: HomeAssistant) -> None:
    """Forget the install history."""
    if install_failure_history := hass.data.get(DATA_INSTALL_FAILURE_HISTORY):
        install_failure_history.clear()

so why can’t the function not be imported and I do anything to fix this or work around it? I tried to google the error message, but I did not find anything that helps me.

I did the update because I tried to install HACS before, but when I wanted to activate the integration it told me my HA version was outdated. So then I did the update and I guess the error might also be caused by the HACS installation. What I did to install HACS was to run

root@DietPi:/mnt/dietpi_userdata/homeassistant# wget -O - https://get.hacs.xyz | bash -

So now I tried moving the hacs files somewhere else, hoping this might avoid the installation of HACS and not cause the error, but I got the same error when trying to restart HA. It was probably a stupid thought anyway, because the installation was done when I ran the script.

Sorry if this a dumb question, sorry for my english and thanks for any helpful advice pointing me in the right direction… I would also appreciate notes from advanced users that no one will bother to help me because the problem is so obvious (like when I missed some instruction) or so specific and unique that it is not worth looking into and rather restore the backup. I do have an up to date backup I can restore, but I would rather figure out what is wrong and how to fix it, also because I would guess that I run into the same issue after trying to update from my backup of 2021.8.8.

Here are some more info about my system (Raspberry Pi 4 with DietPi v7.8.2):

Systemzustand
Version	core-2021.8.8
Installationstyp	Unknown
Entwicklung	false
Supervisor	false
Docker	false
user	homeassistant
Virtuelle Umgebung	false
Python-Version	3.8.10
Betriebssystemfamilie	Linux
Betriebssystem-Version	5.10.63-v8+
CPU-Architektur	aarch64
Zeitzone	Europe/Berlin

Thanks and cheers
Arne

stupid question, did you tried to reinstall HA?

dietpi-software reinstall 157

Not sure if it is needed to install HACS but probably you would need to run the install from within the Customize Python environment ? https://dietpi.com/docs/software/home_automation/#home-assistant

Thanks for your answer!

I did not run the HACS script as homeassistant user (but as root) and nd I did not reinstall HA (so far) - is that a stupid question because I should obviously have done so after installing HACS?

Or should I have reinstalled HA after updating DietPi? It was my first time trying to update HA since I am just using it since a couple of weeks.

But if, from an advanced users take on my situation, a reinstall would be the best thing to do, I will do that. I am still a bit worried that the service won’t start up after it stops now, but I will just pick a moment where I have time to restore my backup if that happens.

Thanks again and cheers
Arne

basically running the update should be fine. Sometimes running a reinstall might fix an issue (no grantee) it was just a question. probably best to restore your system, run dietpi update and run HA update. And not going to install HACS this time.

Usually a dietpi update will habe no impact in running software title as we will update our own scripts and perform some apt package updates.

So I did dare to reboot the pi and it took a while for HA to come back up, but it came up, seems to be working normal and I am now on version 2021.11.3. I guess I don’t need my backup after all. This time :slight_smile:

The log is now flooded with weird data from my router (fritzbox) because HA has apparently discovered it and everything that was ever connected to it :smiley:

And there is a “WARNING (Recorder) [homeassistant.components.recorder.util] Version 3.27.2 of SQLite is not supported; minimum supported version is 3.31.0. Starting with Home Assistant 2022.2 this will prevent the recorder from starting. Please upgrade your database software before then” - I guess I could ignore that one for now and let them be next year me’s problem, as well as the one about “Support for the running Python version 3.8.10 is deprecated and will be removed in Home Assistant 2022.1. Please upgrade Python to 3.9.0 or higher.” :slight_smile:

Thanks and cheers!

what OS you are running

Required Information

  • DietPi version | cat /boot/dietpi/.version
  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN
  • Kernel version | uname -a
root@DietPi:/# cat /boot/dietpi/.version
G_DIETPI_VERSION_CORE=7
G_DIETPI_VERSION_SUB=8
G_DIETPI_VERSION_RC=2
G_GITBRANCH='master'
G_GITOWNER='MichaIng'
G_LIVE_PATCH_STATUS[0]='not applied'
root@DietPi:/# echo $G_DISTRO_NAME $G_RASPBIAN
buster 0
root@DietPi:/# uname -a
Linux DietPi 5.10.63-v8+ #1459 SMP PREEMPT Wed Oct 6 16:42:49 BST 2021 aarch64 GNU/Linux

ok you are on Buster (still). To get a newer version of SQLite and Python you would need to upgrade to Bullseye. Afterwards a reinstall of HA would be needed. We created a blog post and describe the update in general https://dietpi.com/blog/?p=811

Just have a look if you find time.