Homeassistant fail to start after update

I have home assistant running on my Raspberry pi B2. I have upgrade dietpi-update & then regular apt-get update, apt-get upgrade commands. then home assistant fail to start. the logs are like this

 Installing Python with Home Assistant module into pyenv
│  - Command: sudo -u homeassistant dash -c
│ . /home/homeassistant/pyenv-activate.sh
│ pyenv install 3.9.15
│ pyenv local 3.9.15
│ pip3 install --no-cache-dir -U pip setuptools wheel
│ [ -z '' ] || pip3 install --no-cache-dir
│ exec pip3 install --no-cache-dir homeassistant
│  - Exit code: 1
│  - DietPi version: v8.11.2 (MichaIng/master) | HW_MODEL: 2 | HW_ARCH: 2 | DISTRO: 6
│  - Image creator: DietPi Core Team
│  - Pre-image: Raspbian Lite
│  - Error log:
│ Downloading Python-3.9.15.tar.xz...
│ -> https://www.python.org/ftp/python/3.9.15/Python-3.9.15.tar.xz
│ Installing Python-3.9.15...
│ WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
│ Installed Python-3.9.15 to /home/homeassistant/.pyenv/versions/3.9.15
│
│ Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple/
│ Requirement already satisfied: pip in ./.pyenv/versions/3.9.15/lib/python3.9/site-packages (22.0.4)
│ Collecting pip
│   Downloading pip-22.3.1-py3-none-any.whl (2.1 MB)
│      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 5.8 MB/s eta 0:00:00
│ Requirement already satisfied: setuptools in ./.pyenv/versions/3.9.15/lib/python3.9/site-packages (58.1.0)
│ Collecting setuptools
│   Downloading https://www.piwheels.org/simple/setuptools/setuptools-65.6.3-py3-none-any.whl (1.2 MB)
│      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 1.5 MB/s eta 0:00:00
│ Collecting wheel
│   Downloading https://www.piwheels.org/simple/wheel/wheel-0.38.4-py3-none-any.whl (36 kB)
│ Installing collected packages: wheel, setuptools, pip
│   Attempting uninstall: setuptools
│     Found existing installation: setuptools 58.1.0
│     Uninstalling setuptools-58.1.0:
│       Successfully uninstalled setuptools-58.1.0
│   Attempting uninstall: pip
│     Found existing installation: pip 22.0.4 
           =============================DEBUG ASSISTANCE=============================
          If you are seeing a compilation error please try the following steps to
          successfully install cryptography:
          1) Upgrade to the latest pip and try again. This will fix errors for most
             users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
          2) Read https://cryptography.io/en/latest/installation/ for specific
             instructions for your platform.
          3) Check our frequently asked questions for more information:
             https://cryptography.io/en/latest/faq/
          4) Ensure you have a recent Rust toolchain installed:
             https://cryptography.io/en/latest/installation/#rust

          Python: 3.9.15
          platform: Linux-5.15.76-v7+-armv7l-with-glibc2.31
          pip: n/a
          setuptools: 65.6.3
          setuptools_rust: 1.5.2
          rustc: n/a
          =============================DEBUG ASSISTANCE=============================

      error: can't find Rust compiler

      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

      To update pip, run:

          pip install --upgrade pip

      and then retry package installation.

      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.

      This package requires Rust >=1.48.0.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects

I guess you did way more than this. Because you have a failed HA install / re-install process. This has nothing to do with dietpi-update, apt-get update or apt-get upgrade :wink:

The issue is with piwheels.org as we use pre-compiled wheels. Actually, builds for cryptography failded due to Rust dependency. We tried to assist piwheels.org guys but no luck so far.

A possible way around Failed to build cryptography while either updating or installing sabnzbd - #2 by Joulinar

I gave serial wise these commands but still system fail to start home assistant

 curl -sSfL 'https://sh.rustup.rs' -o rustup-init.sh
chmod +x rustup-init.sh
./rustup-init.sh -y --profile minimal
rm rustup-init.sh
source "$HOME/.cargo/env"
dietpi-software install 16 130
apt install libffi-dev libssl-dev
pip3 install cryptography

also in end system show this message

Installing collected packages: pycparser, cffi, cryptography
Successfully installed cffi-1.15.1 cryptography-38.0.4 pycparser-2.21
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv 

so please tell me these command modify as per our home assistant installation. thanks

you can’t follow the link I shared 1:1. This was just an idea on how to work around. You would need to install Rust for HA user. Same for pip3 install cryptography

To do so, you need to activate Customize Python environment as per our online docs. Home Automation Software Options - DietPi.com Docs

sudo -u homeassistant bash
. /home/homeassistant/pyenv-activate.sh
curl -sSfL 'https://sh.rustup.rs' -o rustup-init.sh
chmod +x rustup-init.sh
./rustup-init.sh -y --profile minimal
rm rustup-init.sh
source "$HOME/.cargo/env"
pip3 install cryptography
1 Like

Thanks Joulinar, after your provided commands system & homeassistant updated to latest version & system works fine again. thanks