# Weather hat software failing on Raspberry pi 5?

**URL:** <https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845>\
**Category:** Uncategorized\
**Created:** [3 May 2024 03:31 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845 "2024-05-03T03:31:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phil204480](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/phil204480/32/10317_2.png) [@Phil204480](https://forum.core-electronics.com.au/u/Phil204480)\
**Post date:** [3 May 2024 03:31 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/1 "2024-05-03T03:31:37Z")

</div>

When I run this it fails: git clone [GitHub - pimoroni/weatherhat-python](https://github.com/pimoroni/weatherhat-python)  
cd weatherhat-python  
sudo ./install.sh

The error is i5-larry@raspberrypi:~/weatherhat-python $ ./install.sh  
weatherhat Python Library: Installer

Checking Dependencies. Please wait…  
error: externally-managed-environment

This environment is externally managed

To install Python packages system-wide, try apt install  
python3-xyz, where xyz is the package you are trying to  
install.

---

<div class="post-metadata">

**Author:** ![Pixmusix](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/pixmusix/32/9719_2.png) [@Pixmusix](https://forum.core-electronics.com.au/u/Pixmusix)\
**Post date:** [3 May 2024 04:21 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/2 "2024-05-03T04:21:33Z")

</div>

Hi Phil.

Hope you’re well.  
What is inside install.sh?  
The Pi5 Architectures slightly different from the 4, so the installer may not be pi5 compatible.  
Are you comfortable jumping inside install.sh and looking for any false HALs or hard coded ROM addresses that may no longer exist on pi5?

---

<div class="post-metadata">

**Author:** ![Phil204480](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/phil204480/32/10317_2.png) [@Phil204480](https://forum.core-electronics.com.au/u/Phil204480)\
**Post date:** [3 May 2024 04:42 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/3 "2024-05-03T04:42:10Z")

</div>

Hi Pixmusix, not familiar with the false HAL’s etc…

was reading on the Support - Pimoroni Forum, a few ppl reporting the same…

[Weather hat software failing on Raspberry pi 5 - Support - Pimoroni Buccaneers](https://forums.pimoroni.com/t/weather-hat-software-failing-on-raspberry-pi-5/23323)

Cheers in advance

Phil

---

<div class="post-metadata">

**Author:** ![Pixmusix](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/pixmusix/32/9719_2.png) [@Pixmusix](https://forum.core-electronics.com.au/u/Pixmusix)\
**Post date:** [3 May 2024 05:09 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/4 "2024-05-03T05:09:09Z")

</div>

> [@Phil204480](#):
>
> Hi Pixmusix, not familiar with the false HAL’s etc…

Totally fine. Lets go through it together.  
Here is the code we want to inspect.

> <https://github.com/pimoroni/weatherhat-python/blob/main/install.sh>

The first thing I’d do here is check the error message for something to search.  
This line below is interesting, because it’s probably generated by the code. So let’s search for that.

> Checking Dependencies. Please wait…

Here it is, looks like at minimum we made it to line 139.

```auto
inform "Checking Dependencies. Please wait..."

pip_pkg_install toml

CONFIG_VARS=`$PYTHON - <<EOF
import toml
config = toml.load("pyproject.toml")
p = dict(config['pimoroni'])
# Convert list config entries into bash arrays
for k, v in p.items():
    v = "'\n\t'".join(v)
    p[k] = f"('{v}')"
print("""
APT_PACKAGES={apt_packages}
SETUP_CMDS={commands}
CONFIG_TXT={configtxt}
""".format(**p))
EOF`

```

Looks like we didn’t make it past this CONF\_VARS python file.  
That’s trying to import a toml which is essentially a hardware abstraction config package.  
That’s the kind thing we want to check up on. Let’s find that.

> <https://github.com/pimoroni/weatherhat-python/blob/main/pyproject.toml>

So the first thing I notice is that the toml says we require project 3.7.  
That’s interesting and worth checking.  
The second thing to notice is that this project uses `Hatchling` which is a buildchain.  
I happen to know Hatchling doesn’t like opperating under sudo.  
That actually lines up with something else I noticed

```bash
    if [$(id -u) -eq 0]; then
        printf "Script should not be run as root. Try './install.sh'\n"
        exit 1
    fi

```

So two thing I’d check

1. what version of python and I running.
2. trying running as install.sh as a user, not root.

Let me know how that goes.  
Pix ❣

---

<div class="post-metadata">

**Author:** ![Phil204480](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/phil204480/32/10317_2.png) [@Phil204480](https://forum.core-electronics.com.au/u/Phil204480)\
**Post date:** [3 May 2024 05:45 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/5 "2024-05-03T05:45:38Z")

</div>

Hi Pixmusix,

1. Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
2. ran as ./install.sh not as root.

Phil

---

<div class="post-metadata">

**Author:** ![Pixmusix](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/pixmusix/32/9719_2.png) [@Pixmusix](https://forum.core-electronics.com.au/u/Pixmusix)\
**Post date:** [3 May 2024 06:12 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/6 "2024-05-03T06:12:28Z")

</div>

Hmm.

Ok the next thing I would want to see is this python config file actually looks like.  
Try adding this line to your install.sh file and see if you can get an output.  
I’d put it on line 162 just before the evaluation.

```auto
echo CONFIG_VARS

```

Does it all look good?  
We want it to have a format similar to `apt install python3-xyz`

---

<div class="post-metadata">

**Author:** ![Phil204480](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/phil204480/32/10317_2.png) [@Phil204480](https://forum.core-electronics.com.au/u/Phil204480)\
**Post date:** [3 May 2024 07:10 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/7 "2024-05-03T07:10:54Z")

</div>

that didn’t display any output

if [$? -ne 0]; then

warning “Error parsing configuration…\n”

exit 1

fi

echo CONFIG\_VARS

eval $CONFIG\_VARS

RESOURCES\_DIR=$RESOURCES\_TOP\_DIR/$LIBRARY\_NAME

UNINSTALLER=$RESOURCES\_DIR/uninstall.sh

---

<div class="post-metadata">

**Author:** ![Phil204480](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/phil204480/32/10317_2.png) [@Phil204480](https://forum.core-electronics.com.au/u/Phil204480)\
**Post date:** [3 May 2024 07:11 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/8 "2024-05-03T07:11:32Z")

</div>

there is some further output being generated

Installing for Python 3.11.2…

error: externally-managed-environment

× This environment is externally managed  
╰─\> To install Python packages system-wide, try apt install  
python3-xyz, where xyz is the package you are trying to  
install.

```
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

For more information visit http://rptl.io/venv

```

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.  
hint: See PEP 668 for the detailed specification.  
Setting up i2c and SPI… Backing up /boot/config.txt to /boot/config.preinstall-weatherhat-2024-05-03-16-40-01.txt

/usr/bin/raspi-config: 319: cannot create /boot/firmware/config.txt.bak: Permission denied  
mv: cannot stat ‘/boot/firmware/config.txt.bak’: No such file or directory  
sed: couldn’t open temporary file /etc/modprobe.d/sedv3hM1f: Permission denied

- Must be run as root - try ‘sudo dtparam …’  
/usr/bin/raspi-config: 319: cannot create /boot/firmware/config.txt.bak: Permission denied  
mv: cannot stat ‘/boot/firmware/config.txt.bak’: No such file or directory  
sed: couldn’t open temporary file /etc/modprobe.d/sedTO0HcE: Permission denied  
sed: couldn’t open temporary file /etc/sedCr1jgV: Permission denied
- Must be run as root - try ‘sudo dtparam …’  
Would you like to copy examples to /home/phil.kern/Pimoroni/weatherhat? [y/N] n

Would you like to generate documentation? [y/N]

---

<div class="post-metadata">

**Author:** ![Jaryd](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jaryd/32/8778_2.png) [@Jaryd](https://forum.core-electronics.com.au/u/Jaryd)\
**Post date:** [3 May 2024 07:12 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/9 "2024-05-03T07:12:19Z")

</div>

Hey Phil,

With the Pi 5 and Bookworm OS, something that has caught everyone off guard is that we need to use virtual environments when installing packages system-wide with pip, and this may be giving you an error.  
We have a [fix for it](https://core-electronics.com.au/guides/raspberry-pi/using-virtual-environments-in-thonny-on-a-raspberry-pi/), but this is in thonny. I haven’t ever set up a virtual environment outside of Thonny, but here is an [Adafruit tutorial](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi/overview) on it.

Its suuuuper annoying and the folks at Raspberry Pi Foundation express their dislike of it, its out of their control.

Hope this helps

-Jaryd

---

<div class="post-metadata">

**Author:** ![Pixmusix](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/pixmusix/32/9719_2.png) [@Pixmusix](https://forum.core-electronics.com.au/u/Pixmusix)\
**Post date:** [3 May 2024 07:13 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/10 "2024-05-03T07:13:21Z")

</div>

> [@Phil204480](#):
>
> ```auto
> If you wish to install a non-Debian-packaged Python package,
> create a virtual environment using python3 -m venv path/to/venv.
> Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
> sure you have python3-full installed.
> 
> For more information visit http://rptl.io/venv
> 
> ```

AHH!! That’s the problem!  
@Jaryd seems to have a solution.

---

<div class="post-metadata">

**Author:** ![Phil204480](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/phil204480/32/10317_2.png) [@Phil204480](https://forum.core-electronics.com.au/u/Phil204480)\
**Post date:** [3 May 2024 07:15 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/11 "2024-05-03T07:15:22Z")

</div>

will scope it…  
will update you…

Phil

---

<div class="post-metadata">

**Author:** ![Phil204480](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/phil204480/32/10317_2.png) [@Phil204480](https://forum.core-electronics.com.au/u/Phil204480)\
**Post date:** [4 May 2024 01:11 UTC](https://forum.core-electronics.com.au/t/weather-hat-software-failing-on-raspberry-pi-5/19845/12 "2024-05-04T01:11:23Z")

</div>

Hey Jaryd,  
I will try the thony version as I wasn’t having any luck with the Adafruit version.  
will update you.

Cheers in advance

Phil
