Powerwall-Dashboard
Powerwall-Dashboard copied to clipboard
Raspbian GNU/Linux 10 (buster): Fatal Python error: pyinit_main: can't initialize
From: #54 and https://github.com/jasonacox/Powerwall-Dashboard/discussions/55
Python Error for pyPowerwall
Running setup.sh
on a Raspberry Pi running Raspbian GNU/Linux 10 (buster) works successfully but the pypowerwall container fails to start. Running docker logs pypowerwall
shows errors in the log:
Current thread 0xb6f3c390 (most recent call first): <no Python frame>
Fatal Python error: pyinit_main: can't initialize time
Python runtime state: core initialized
PermissionError: [Errno 1] Operation not permitted
The Cause
This is caused by a bug in libseccomp2 related to docker container images based on Ubuntu and Alpine. The container for pypowerwall used an Alpine Python 3.8 container base.
This error shows up for several python projects using docker running on Raspbian Buster (as I discovered via a google search). See https://blog.samcater.com/fix-workaround-rpi4-docker-libseccomp2-docker-20/ and also https://docs.linuxserver.io/faq in section "My host is incompatible with images based on Ubuntu Focal and Alpine 3.13 and later. This only affects 32 bit installs of distros based on Debian Buster."
The Fix
Obviously, the first fix would be to upgrade your OS to the latest Raspbian (bullseye) but I understand that may not be possible and is a bit involved.
There are several other ways to get the fixed libseccomp2 installed. The best approach seems to be using the backports (where the libseccomp2 code is backported to legacy OS versions like Buster):
# Get signing keys to verify the new packages
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 04EE7237B7D453EC 648ACFD622F3D138
# Add the Buster backport repository to apt sources.list
echo 'deb http://httpredir.debian.org/debian buster-backports main contrib non-free' | sudo tee -a /etc/apt/sources.list.d/debian-backports.list
sudo apt update
sudo apt install libseccomp2 -t buster-backports
# I recommend you restart and see if that corrects the problem
If the above didn't work, there is a brute force way to get the libseccomp2 upgrade from debian.
wget http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.4.4-1~bpo10+1_armhf.deb
sudo dpkg -i libseccomp2_2.4.4-1~bpo10+1_armhf.deb