Having put a Weather HAT on my Pi4 - running Buster - I’ve gone through the Getting Started article to run:
pip3 install weatherhat
git clone GitHub - pimoroni/weatherhat-python
cd weatherhat-python
sudo ./install.sh
The last line fails, because running scripts should not be run as root, so I run it without, and it throws the following error:
/usr/bin/raspi-config: 232: /usr/bin/raspi-config: cannot create /boot/config.txt.bak: Permission denied
mv: cannot stat ‘/boot/config.txt.bak’: No such file or directory
sed: couldn’t open temporary file /etc/modprobe.d/sed2panSk: Permission denied
- Must be run as root - try ‘sudo dtparam …’
/usr/bin/raspi-config: 232: /usr/bin/raspi-config: cannot create /boot/config.txt.bak: Permission denied
mv: cannot stat ‘/boot/config.txt.bak’: No such file or directory
sed: couldn’t open temporary file /etc/modprobe.d/sedgEtnLm: Permission denied
sed: couldn’t open temporary file /etc/sedDHVpWl: Permission denied
- Must be run as root - try ‘sudo dtparam …’
Installing the examples and running basic.py (after correcting multiple syntax errors) it throws the error:
Traceback (most recent call last):
File “basic.py”, line 3, in
import weatherhat
ImportError: No module named weatherhat
Is there a different way to install the module?
Update: running a python script to find the paths:
import sys
import pprint
pprint.pprint(sys.path)
The path Python was looking for was /home/pi/.local/lib/python3.7/site-packages. I moved the module to /usr/local/lib/python3.7/dist-packages and it now detects.
Now it’s throwing a Failed to add edge detection. I’ve tried reinstalling the Pi, and it still fails.
File "basic.py", line 5, in <module>
sensor = weatherhat.WeatherHAT()
File "/usr/local/lib/python3.7/dist-packages/weatherhat/__init__.py", line 80, in __init__
self._ioe.on_interrupt(self.handle_ioe_interrupt)
File "/usr/local/lib/python3.7/dist-packages/ioexpander/__init__.py", line 410, in on_interrupt
self._gpio.add_event_detect(self._interrupt_pin, self._gpio.FALLING, callback=callback, bouncetime=1)
RuntimeError: Failed to add edge detection
I have been having the same problem. Really frustrating
I think ultimately it was because I hadn’t plugged in the rain sensor and it was trying to access it.
At the time I got it working without plugging that in by (a) moving the Weatherhat package; which had installed/was referring to the absolute path - home/pi/usr/local/lib - while the Python system path - python -c “import sys; print(sys.path)” - was looking elsewhere, so moving the file to another folder looked to alleviate it.
(b) I also went through the file listed in the error and tried commenting out those errant lines.