Warning Cookies are used on this site to provide the best user experience. If you continue, we assume that you agree to receive cookies from this site. OK

Installing Home Assistant Core in a python virtual environment

Links to documentation:

The following is an example of installing Home Assistant Core on JetHome controllers with Armbian OS in a python virtual environment. This guide is also suitable for installing Home Assistant Core on Ubuntu Linux.

Preparing for installation

For Home Assistant Core to work, it is recommended to use python version 3.9 or higher (since Home Assistant Core 2022.* versions, previous versions of python will not be supported). Check the version of python3 installed on your system:

 python3 --version

If python version 3.9 is already installed and used on the system, then it is enough to additionally install the following packages:

 sudo apt update
sudo apt install python3-dev python3-pip python3-venv libffi-dev build-essential

If you are using python version 3.8 or lower, then you must also install python version 3.9 first:

 sudo apt update
sudo apt install python3.9 python3.9-dev python3.9-venv python3-pip libffi-dev build-essential

Installing Home Assistant

The following is an example of installing Home Assistant Core in the home directory of the current user. To install, run the following commands:

 cd ~
python3.9 -m venv homeassistant
cd home assistant
source bin/activate
python3 -m pip install wheel
pip3 install homeassistant

Please note that when creating a virtual environment, you must use python version 3.9

Home Assistant's working directory, which stores the configuration file and log files, in this case will be ~/.homeassistant

Start Home Assistant

To start Home Assistant, you need to execute the command (without leaving the virtual environment):


After a while, you will be able to connect to the system through a browser at: :8123. Installing and launching Home Assistant for the first time takes a long time.

To automatically start Home Assistant at system boot, you need to create the file /etc/systemd/system/home-assistant@$USER.service (where $USER is the login under which Home Assistant was installed):

 sudo nano /etc/systemd/system/home-assistant@$USER.service

File contents:

Description=Home Assistant
ExecStart=/home/%i/homeassistant/bin/hass -c "/home/%i/.homeassistant"


and activate this service:

 sudo systemctl enable home-assistant@$USER.service

Launching Home Assistant:

 sudo systemctl start home-assistant@$USER.service