Stuck in Python prerequisite loop

I want to install HASS core on an AlmaLinux 9 VM. (for various reasons). With the help of this website I have gotten close to installed. But I’m stuck with conflicting prerequisite Python packages as shown below. I’m not sure how to untangle this. Can someone help?

homeassistant 2023.1.7 has requirement attrs==22.1.0, but you have attrs 23.1.0.
homeassistant 2023.1.7 has requirement pyyaml==6.0, but you have pyyaml 5.4.1.

After lots of messing with packages I couldn’t get further than

(hass) [hass@lserver2 hass]$ pip check
referencing 0.24.0 has requirement attrs>=22.2.0, but you have attrs 22.1.0.
piper-tools 0.4.0 has requirement PyYAML<6.0.0,>=5.4.1, but you have pyyaml 6.0.
jsonschema-specifications 2023.6.1 has requirement referencing>=0.28.0, but you have referencing 0.24.0.

Being new to Python, I discovered that if I ask pip to install all of the conflicting packages (without verions numbers) it steps back versions until a compatible combination is found. But this ran for a long time going back to HomeAssistant 2021.x.x until I cancelled.

Is there a way to make HASS core work? If not, if I installed a container with HASS will that solve my problem? (I’m new to containers too…so I’m not sure if the container would have the same Python prerequisite conflicts)

I gave up and switched to a container on AlmaLinux 9.

I completed a 2023.9.2 HA core installation using AlmaLinux 9 distro in a VM running on ESXi 7.0 Update 3. @ocgltd your installation via a container is probably a better solution and is recommended over core. I used in the past HA core on a CentOS 7 distro to simplify the installation of Socat to access my Z-Wave stick connected to a Raspberry Pi. Now Socat is not needed anymore with the addition of Z-Wave JS UI, but it is hard to change old habits, I am going to stick with core. I have found during my past experiences doing these core installs of HA, AppDaemon, ESPHome, etc… on a CentOS 7 VM that uses the core python from the distro is not ideal. I prefer installing the appropriate versions of Python separately, this gives me more flexibility with the install.

To compile Python from the source you are going to need the dev packages. Do first an update of your distro and fetch the following:

dnf install wget yum-utils make gcc gcc-c++ systemd-devel openssl-devel bzip2 bzip2-devel libffi-devel zlib-devel readline-devel sqlite-devel xz-devel tk-devel gdbm-libs ncurses-devel libjpeg-turbo-devel giflib tar git

Note: some of the above packages are not needed to build Python but they have been useful for my use of HA. I do my build of Python in: /usr/src:

cd /usr/src

Downloaded the Python version needed:

wget https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tgz & tar xzf Python-3.11.5.tgz

Note: nproc will provide the number of CPU used in the compile. You will need enough memory to compile the optimizations i.e. --enable-optimizations. My vm setup uses 2 vCPUs and 2 GB of memory:

cd Python-3.11.5
./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions --enable-optimizations
make -j ${nproc}
make altinstall

Check the Python version:

python3.11 -V

Hopefully the above worked i.e., Python 3.11.5. Time to use the above build. I create my HA virtual env in folder: /srv/homeassistant and my user is: homeassistant

mkdir /srv/homeassistant
useradd -rm homeassistant
chown homeassistant:homeassistant /srv/homeassistant

Create the Python virtual environment pip package installation as role user homeassistant, creates the folder structure and configuration for the Python virtual env.

sudo -u homeassistant -H -s
/usr/local/bin/python3.11 -m venv /srv/homeassistant

Activate the Virtual Environment i.e. for Python 3.11.5. Download the appropriate runtime modules. Note there is a bug: module 'urllib3.util' has no attribute 'PROTOCOL_TLS' · Issue #95192 · home-assistant/core · GitHub and I had to retrieve the fix using git:

source /srv/homeassistant/bin/activate
python -m pip install wheel
pip install homeassistant
pip install git+https://github.com/boto/botocore

And voila I hope you can run HA:

hass

Ctrl C to leave HA

Exit user homeassistant

exit

You can configure the Autostart configuration using systemd

Documented at multiple places: Autostart using systemd in /etc/systemd/system/[email protected]

[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=%i
WorkingDirectory=/home/%i/.homeassistant
ExecStart=/srv/homeassistant/bin/hass -c “/home/%i/.homeassistant”
RestartForceExitStatus=100

[Install]
WantedBy=multi-user.target

Resolve SELinux permission issues: Getting "Permission Denied" When Trying to Auto-Start (HA Works Great Otherwise!), I changed the permission in conf file: /etc/selinux/config

SELINUX = permissive

Start and enable the service:

systemctl --system daemon-reload
systemctl start home-assistant@homeassistant
systemctl enable home-assistant@homeassistant

To complete the above instruction. I recently investigated: SELinux a little more. I came up with what I believe or I hope a better solution that does not dilute the security of the server by making it: SELINUX=permissive

Change back the SELinux configuration from: SELINUX=permissive to SELINUX=enforcing.

I then tried the following suggestion from @elajoie: Getting “Permission Denied” When Trying to Auto-Start (HA Works Great Otherwise!)

chcon system_u:object_r:systemd_unit_file_t:s0 /etc/systemd/system/[email protected]

Good but it was not sufficient. I got the following error when starting the service:


Nov 20 09:46:47 homeassistant.cognoquest.org systemd[1395]: [email protected]: Failed at step EXEC spawning /srv/homeassistant/bin/hass: Permission denied

Hence I needed to also change: /srv/homeassistant/bin/hass SELinux permission:

chcon system_u:object_r:bin_t:s0 /srv/homeassistant/bin/hass