Installation on a Raspberry Pi 5

You have questions or need help around BierBot Bricks - this is the right place.
Post Reply
User avatar
Rüdiger
Posts: 4
Joined: Wed May 08, 2024 2:12 pm

Installation on a Raspberry Pi 5

Post by Rüdiger »

Hello together,

maybe a interesting solution for you with new Hardware:

After a purchase of a RPI5 I changed the setup like described in:
https://bierbot.com/blog/howto/howto-bu ... g-control/
with the changed setups of
https://github.com/BernhardSchlegel/Bie ... Pi/pull/19

So far so good. During install I´ve had the problem with pip3:

Code: Select all

sudo pip3 install -r requirements.txt

Code: Select all

error: externally-managed-environment

Then i´ve found the problem:
From Bookworm onwards, packages installed via pip must be installed into a Python Virtual Environment using venv. This has been introduced by the Python community, not by Raspberry Pi; see PEP 668 for more details.
Source: https://www.raspberrypi.com/documentati ... rs/os.html
Nevertheless to get the installation running i used the command

Code: Select all

pip3 install *** –break-system-package
To install all required pips:
requests>=2.26.0
rpi-lgpio>=0.4
click>=8.0.1
pyyaml>=5.4.1
w1thermsensor>=2.0.0
types-requests>=2.28.11.17

Since then setup.py was working nicely.

After a reboot the Brick just not wanted to show up on the website and the bricks.log was empty. So after a manual start of the main.py with Thonny it worked fine. Brick was online found.

Therefore Bernhard and I found out, that the main.py is not starting automaticly.
A result is still open.

If somebody has an idea to implement the autostart again properly let us know :D

Keep fresh
User avatar
Bernhard
Site Admin
Posts: 259
Joined: Sun Jan 23, 2022 3:53 pm
Location: Munich - Germany

Re: Installation on a Raspberry Pi 5

Post by Bernhard »

Hey Rüdiger,

thanks for going public ! :)

As a next step, we should debug, why the bierbot.service is not starting (it's supposed to be setup during the execution of setup.py).

To check the logs from the service since last reboot, the following command might help:

Code: Select all

journalctl -u bierbot.service -b
Cheers,
Bernhard.
Chuckg
Posts: 55
Joined: Tue Feb 21, 2023 8:05 pm

Re: Installation on a Raspberry Pi 5

Post by Chuckg »

Rüdiger,

Here is a link to my fork for bookworm. I ran through it several times on an RPI4 and RPI5. I think it covers everything. The move to virtual environments meant some changes to the setup process, setup script and the startup script. Additionally, they dropped support for RPI.GPIO so a different python package is needed and there was some changes to support that.

I updated the README.md on this fork to support install with bookworm.

https://github.com/ChuckGl/BierBot-Bric ... e/bookworm


ChuckG
User avatar
Bernhard
Site Admin
Posts: 259
Joined: Sun Jan 23, 2022 3:53 pm
Location: Munich - Germany

Re: Installation on a Raspberry Pi 5

Post by Bernhard »

Hey Rüdiger,

as I have currently no time testing the RPi repo, a quick confirmation from yourside would be awesome if the branch from Chuck works for you. I would take that as GO to merge the branch.

I believe, however, Rüdiger already found your branch and used it?

Cheers,
Bernhard.
User avatar
Rüdiger
Posts: 4
Joined: Wed May 08, 2024 2:12 pm

Re: Installation on a Raspberry Pi 5

Post by Rüdiger »

Bernhard wrote: Tue May 14, 2024 1:00 pm [...]
As a next step, we should debug, why the bierbot.service is not starting (it's supposed to be setup during the execution of setup.py).

To check the logs from the service since last reboot, the following command might help:

Code: Select all

journalctl -u bierbot.service -b
[...]
The results of the journalctl is:

Code: Select all

admin@BeerPi:~ $ journalctl -u bierbot.service -b
Mai 14 14:32:50 BeerPi systemd[1]: Started bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:50 BeerPi (python3)[844]: bierbot.service: Failed to locate executable /home/admin/Desktop/BierBot-Bricks-RaspberryPi/.env/bin/python3: No such >
Mai 14 14:32:50 BeerPi (python3)[844]: bierbot.service: Failed at step EXEC spawning /home/admin/Desktop/BierBot-Bricks-RaspberryPi/.env/bin/python3: No such>
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Main process exited, code=exited, status=203/EXEC
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Failed with result 'exit-code'.
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Scheduled restart job, restart counter is at 1.
Mai 14 14:32:50 BeerPi systemd[1]: Stopped bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:50 BeerPi systemd[1]: Started bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Main process exited, code=exited, status=203/EXEC
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Failed with result 'exit-code'.
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Scheduled restart job, restart counter is at 2.
Mai 14 14:32:50 BeerPi systemd[1]: Stopped bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:50 BeerPi systemd[1]: Started bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:50 BeerPi (python3)[916]: bierbot.service: Failed to locate executable /home/admin/Desktop/BierBot-Bricks-RaspberryPi/.env/bin/python3: No such >
Mai 14 14:32:50 BeerPi (python3)[916]: bierbot.service: Failed at step EXEC spawning /home/admin/Desktop/BierBot-Bricks-RaspberryPi/.env/bin/python3: No such>
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Main process exited, code=exited, status=203/EXEC
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Failed with result 'exit-code'.
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Scheduled restart job, restart counter is at 3.
Mai 14 14:32:50 BeerPi systemd[1]: Stopped bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:50 BeerPi (python3)[977]: bierbot.service: Failed to locate executable /home/admin/Desktop/BierBot-Bricks-RaspberryPi/.env/bin/python3: No such >
Mai 14 14:32:50 BeerPi (python3)[977]: bierbot.service: Failed at step EXEC spawning /home/admin/Desktop/BierBot-Bricks-RaspberryPi/.env/bin/python3: No such>
Mai 14 14:32:50 BeerPi systemd[1]: Started bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Main process exited, code=exited, status=203/EXEC
Mai 14 14:32:50 BeerPi systemd[1]: bierbot.service: Failed with result 'exit-code'.
Mai 14 14:32:51 BeerPi systemd[1]: bierbot.service: Scheduled restart job, restart counter is at 4.
Mai 14 14:32:51 BeerPi systemd[1]: Stopped bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:51 BeerPi systemd[1]: Started bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:51 BeerPi systemd[1]: bierbot.service: Main process exited, code=exited, status=203/EXEC
Mai 14 14:32:51 BeerPi systemd[1]: bierbot.service: Failed with result 'exit-code'.
Mai 14 14:32:51 BeerPi systemd[1]: bierbot.service: Scheduled restart job, restart counter is at 5.
Mai 14 14:32:51 BeerPi systemd[1]: Stopped bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.
Mai 14 14:32:51 BeerPi systemd[1]: bierbot.service: Start request repeated too quickly.
Mai 14 14:32:51 BeerPi systemd[1]: bierbot.service: Failed with result 'exit-code'.
Mai 14 14:32:51 BeerPi systemd[1]: Failed to start bierbot.service - runs the BierBot Bricks RaspberryPi client after startup.


User avatar
Rüdiger
Posts: 4
Joined: Wed May 08, 2024 2:12 pm

Re: Installation on a Raspberry Pi 5

Post by Rüdiger »

Chuckg wrote: Tue May 14, 2024 5:35 pm Here is a link to my fork for bookworm. I ran through it several times on an RPI4 and RPI5. I think it covers everything. The move to virtual environments meant some changes to the setup process, setup script and the startup script. Additionally, they dropped support for RPI.GPIO so a different python package is needed and there was some changes to support that.

I updated the README.md on this fork to support install with bookworm.

https://github.com/ChuckGl/BierBot-Bric ... e/bookworm
Hi ChuckG,

because I´m new to the GitHub I was looking what you´ve changed in the files and copied the changes (from https://github.com/BernhardSchlegel/Bie ... l/19/files) into the actual setup files from Bernhard by hand. And the installation was running ok.
Was still wondering if there is no easier way :D

When you say it could be a difference to use directly your https://github.com/ChuckGl/BierBot-Bricks-RaspberryPi as installation, I would try to start from the beginning and reinitialize my Pi OS and start all over again.

@Bernhard
Can this work? When I change the "git clone to Chuckg`s link?

Code: Select all

cd ~/Desktop
git clone https://github.com/ChuckGl/BierBot-Bricks-RaspberryPi.git
cd BierBot-Bricks-RaspberryPi
sudo pip3 install -r requirements.txt
python3 setup.py
Thanks for your help
Chuckg
Posts: 55
Joined: Tue Feb 21, 2023 8:05 pm

Re: Installation on a Raspberry Pi 5

Post by Chuckg »

I would say if it easy to reinstall the Pi OS for you, do that. Remember to do the updates first:

sudo apt update
sudo apt upgrade
sudo reboot

I just realized when I updated the README.md, I did it as if it was updating Bernhard's repo. Here is the install direction if you are cloning my bookworm updates.

1: Steps to install BierBot-Brick for Raspberry Pi (The checkout was missing. This pulls the bookworm fork not the original)

git clone https://github.com/ChuckGl/BierBot-Bric ... erryPi.git
cd BierBot-Bricks-RaspberryPi
git checkout bookworm
git clone https://github.com/BernhardSchlegel/Bie ... erryPi.git
cd BierBot-Bricks-RaspberryPi

2: Setup python virtual environment (Required for Bookworm as python 3.11 want to isolate python environments now for security and stability)

python3 -m venv .env && source .env/bin/activate && pip install -r requirements_bookworm.txt

3: Link virtual environment to system-level lgpio package. The lgpio package in combination with rpi-lgpio replaces RPi.GPIO in bookworm. The lgpio package is managed using apt which is not supported in virtual environments. This gets around that issue for now.
ln -s /usr/lib/python3/dist-packages/lgpio.py $VIRTUAL_ENV/lib/python3.11/site-packages/lgpio.py
ln -s /usr/lib/python3/dist-packages/lgpio-0.2.2.0.egg-info $VIRTUAL_ENV/lib/python3.11/site-packages/lgpio-0.2.2.0.egg-info
ln -s /usr/lib/python3/dist-packages/_lgpio.cpython-311-aarch64-linux-gnu.so $VIRTUAL_ENV/lib/python3.11/site-packages/_lgpio.cpython-311-aarch64-linux-gnu.so

4: Run the setup.py
sudo -E env PATH=$PATH python3 setup.py

Alternatively after you reinstall, you could download the zip file and install that way. But you would still need to follow steps 2 - 4. Replace step 1 with:
wget https://github.com/ChuckGl/BierBot-Bric ... okworm.zip
unzip bookworm.zip
mv BierBot-Bricks-RaspberryPi-bookworm BierBot-Bricks-RaspberryPi
cd BierBot-Bricks-RaspberryPi


Regardless of how you get the code on your Pi, the critical part is steps 2 -4. Those steps make things work with bookworm and RPi5.


Once you install if you run BierBot manually you will need to do this:
cd BierBot-Bricks-RaspberryPi
source .env/bin/activate
python3 main.py

Let me know how it goes and how you decided to do it.


ChuckG
User avatar
Rüdiger
Posts: 4
Joined: Wed May 08, 2024 2:12 pm

Re: Installation on a Raspberry Pi 5

Post by Rüdiger »

This is an amazing work you did for me :D
Therefore I did the big wipe-out and made a new SD with RPI-OS (64Bit)

Here my results:
git clone https://github.com/ChuckGl/BierBot-Bric ... erryPi.git
cd BierBot-Bricks-RaspberryPi
git checkout bookworm
git clone https://github.com/BernhardSchlegel/Bie ... erryPi.git
cd BierBot-Bricks-RaspberryPi
Worked well
python3 -m venv .env && source .env/bin/activate && pip install -r requirements_bookworm.txt
had to go one back with "cd ..", because i had now a structure with "/home/admin/BierBot-Bricks-RaspberryPi/BierBot-Bricks-RaspberryPi". The first one had the bookworm.txt file.
After that it was running through all installs

Code: Select all

Installing collected packages: lgpio, urllib3, rpi-lgpio, pyyaml, idna, click, charset-normalizer, certifi, w1thermsensor, types-requests, requests
Successfully installed certifi-2024.2.2 charset-normalizer-3.3.2 click-8.1.7 idna-3.7 lgpio-0.2.2.0 pyyaml-6.0.1 requests-2.31.0 rpi-lgpio-0.6 types-requests-2.31.0.20240406 urllib3-2.2.1 w1thermsensor-2.3.0
ln -s /usr/lib/python3/dist-packages/lgpio.py $VIRTUAL_ENV/lib/python3.11/site-packages/lgpio.py
ln -s /usr/lib/python3/dist-packages/lgpio-0.2.2.0.egg-info $VIRTUAL_ENV/lib/python3.11/site-packages/lgpio-0.2.2.0.egg-info
ln -s /usr/lib/python3/dist-packages/_lgpio.cpython-311-aarch64-linux-gnu.so $VIRTUAL_ENV/lib/python3.11/site-packages/_lgpio.cpython-311-aarch64-linux-gnu.so
That gave me this back:

Code: Select all

ln: failed to create symbolic link '/home/admin/BierBot-Bricks-RaspberryPi/.env/lib/python3.11/site-packages/lgpio.py': File exists
sudo -E env PATH=$PATH python3 setup.py
Was running smoothly

Restart and BÄM... everytime I restart the system now the Brick is directly found. :mrgreen: Thx ChuckG
User avatar
Bernhard
Site Admin
Posts: 259
Joined: Sun Jan 23, 2022 3:53 pm
Location: Munich - Germany

Re: Installation on a Raspberry Pi 5

Post by Bernhard »

Thanks Rüdiger for reporting back!
Thanks Chuck for the awesome PR which is now the new master :)

Cheers,
Bernhard.
Post Reply