First install (core): 404: Not Found

The logs mentioned several times that HA can’t import sqlite3. So I’d follow Olivier1974’s suggestion and check prerequisites.

Here it is:

root@raspberrypi:~# netstat -an | grep 8123
tcp        0      0 0.0.0.0:8123            0.0.0.0:*               LISTEN     
tcp6       0      0 :::8123                 :::*                    LISTEN

root@raspberrypi:~# ss -a | grep 8123
tcp               LISTEN                 0                   0                                                                 0.0.0.0:8123                                                              0.0.0.0:*                              
tcp               LISTEN                 0                   0                                                                       *:8123                        

root@raspberrypi:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:f5:60:40 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.88/24 brd 192.168.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 2a01:e0a:457:7f00:1161:9307:a768:7904/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 86179sec preferred_lft 86179sec
    inet6 fe80::8243:3fd7:4e1d:fd6d/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether dc:a6:32:f5:60:41 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.89/24 brd 192.168.0.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever
    inet6 2a01:e0a:457:7f00:c92f:9802:1636:2da6/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 86179sec preferred_lft 86179sec
    inet6 fe80::fd32:7565:aeb8:3e01/64 scope link 
       valid_lft forever preferred_lft forever

Attempt to connect to http://192.168.0.88:8123/ leads to 404: Not Found

I have followed the guide and installed the dependencies as required, used venv, set python 3.10:

(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ python --version
Python 3.10.10

ok, I am going to check other install instructions for sqlite3 and possibly other things.

sqlite3 is already installed on my RP. Up to now, I don’t find installation tutorials that require other dependencies.

It looks like to be a sqlite3 version compatibility issue.

I’ve no issue, but I had to install Python 3.10.9 and in the venv, sqlite is installing whatever version is needed by HA.
That’s the beauty of a venv, every software its own version of the packages.

I have installed sqlite3 v3.41.0 in /opt/sqlite:

(homeassistant) homeassistant@raspberrypi:~ $ ls -l /opt/sqlite/lib
total 12280
-rw-r--r-- 1 root root 6985348 f�vr. 26 23:07 libsqlite3.a
-rwxr-xr-x 1 root root     983 f�vr. 26 23:07 libsqlite3.la
lrwxrwxrwx 1 root root      19 f�vr. 26 23:07 libsqlite3.so -> libsqlite3.so.0.8.6
lrwxrwxrwx 1 root root      19 f�vr. 26 23:07 libsqlite3.so.0 -> libsqlite3.so.0.8.6
-rwxr-xr-x 1 root root 5575240 f�vr. 26 23:07 libsqlite3.so.0.8.6
drwxr-xr-x 2 root root    4096 f�vr. 26 23:07 pkgconfig

Then I have exported the path:

(homeassistant) homeassistant@raspberrypi:~ $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sqlite/lib

Run hass again, but I have the same issue.

(homeassistant) homeassistant@raspberrypi:~ $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sqlite/lib
(homeassistant) homeassistant@raspberrypi:~ $ hass
2023-02-26 23:15:29.250 ERROR (MainThread) [homeassistant.setup] Setup failed for analytics: Unable to import component: No module named '_sqlite3'

Does HA install itself sqlite in venv? Isn’t venv only for Python?

That’s an excellent question, and unfortunately, I’m not certain.
However, it appears that it installs SQLAlchemy 2.0.4, and from a Python standpoint, it enables the manipulation of the sqlite3 database in the homeassistant directory.

I don’t have any sqlite packages installed otherwise, but I do have numerous apt packages that are incompatible with what HA installs in the venv. In the past, following the venv creation from the installation guide has always resolved my conflicts.

Moreover, I no longer use the sqlite3 DB because it was on the SD card, and I encountered corruption issues previously. Currently, the HA database is on my NAS using MariaDB.

If you have created the venv, then we need to investigate the matter further.

Yes, I did I follow the guide, installed the dependencies and used venv with python 3.10. I am blocked.

I assume that you really need sqlite for something else …
How did you install it?
From sqlite-devel and libsqlite3-dev packages or compiling it?
Did you (re)compile python3.10 after installing it?

For what it’s worth, I don’t have sqlite3 installed but can use the sqlite3 module in the python3.10 venv of HA:

(homeassistant) homeassistant@hassbian:~/.homeassistant $ python3
Python 3.10.9 (main, Feb  2 2023, 09:53:17) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> print(sqlite3.version)
2.6.0

But it is an old version compared to the one you installed.

In your linked post, did you try the solution of exporting the LD_LIBRARY_PATH before starting hass as suggested in post #18

Here is how I built Python 3.10:

# How to Install Python 3.10.7 on the Raspberry Pi - https://aruljohn.com/blog/python-raspberrypi/
sudo su -
wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev
tar -xzvf Python-3.10.10.tgz
cd Python-3.10.10/
./configure --enable-optimizations
sudo make altinstall
# test
/usr/local/bin/python3.10 -V
	Python 3.10.10

Then venv:

apt-get update
apt-get upgrade -y
apt-get install -y python3 python3-dev python3-venv python3-pip bluez libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0-dev tzdata
useradd -rm homeassistant -G dialout,gpio,i2c
mkdir /srv/homeassistant
chown homeassistant:homeassistant /srv/homeassistant
sudo -u homeassistant -H -s
cd /srv/homeassistant
python3.10 -m venv .
source bin/activate
python -m pip install --upgrade pip
python3 -m pip install wheel

Rust was also needed: curl https://sh.rustup.rs -sSf | sh

Then HA following the official procedure for core install : pip3 install homeassistant==2023.2.5

As it was complaining about sqlite3 as already depicted in my former post, I have installed it:

sudo chmod a+wr /opt
cd /opt
wget https://sqlite.org/2023/sqlite-autoconf-3410000.tar.gz
tar -xvf sqlite-autoconf-3410000.tar.gz
cd sqlite-autoconf-3410000
./configure --prefix=/opt/sqlite
make
sudo make install

And finally run hass

My python does not see the sqlite3 module:

(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ python
Python 3.10.10 (main, Feb 26 2023, 09:31:27) [GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/sqlite3/__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.10/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

If I try:


(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sqlite/lib hass
2023-02-28 18:40:10.462 ERROR (MainThread) [homeassistant.setup] Setup failed for analytics: Unable to import component: No module named '_sqlite3'
2023-02-28 18:40:10.521 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of onboarding. Setup failed for dependencies: analytics

hass still complains and the service does not start.

Same with export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sqlite/lib before running hass.

I could not try to edit /etc/systemd/system/[email protected] since I do not have this file.

Even after the LD_LIBRARY_PATH export, python still does not see sqlite3. But what puzzles me is that you say it is not necessary.

I swear that it is not installed on my system, here is a “proof” :slight_smile:

(homeassistant) homeassistant@hassbian:~/.homeassistant $ python3
Python 3.10.9 (main, Feb  2 2023, 09:53:17) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> print(sqlite3.version)
2.6.0
>>>
(homeassistant) homeassistant@hassbian:~/.homeassistant $ which sqlite3
(homeassistant) homeassistant@hassbian:~/.homeassistant $ sqlite3
bash: sqlite3: command not found

I have tried the suggestion of dc125 here unsuccessfully.

Ok, I think this was the aim of my question here.

But glad you made it.

libsqlite3-dev, then I recompiled python3.10 with the option ./configure --enable-optimizations --enable-loadable-sqlite-extensions