mqtt-io icon indicating copy to clipboard operation
mqtt-io copied to clipboard

DHT22 Adafruit_DHT problem

Open alexfrench opened this issue 3 months ago • 3 comments

I am setting up mqtt-io on a new RPi. Previously this has been very simple and works well. Thank you! I'm hoping someone might be able to offer a solution for my current issue.

Previously, I followed instructions and downloaded the repo, then from the repo folder I ran: python -m pip install . The latest version suggests using pip3 install mqtt-io instead. However, this gives an error:

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.

I settled on using the below which seems to work around the install issues:

pip3 install mqtt-io==2.2.9 --break-system-packages
pip3 install paho-mqtt==1.6.1 --break-system-packages

The install seems to work until I add a DHT22 sensor (working fine on earlier installs) when I see the following:

2024-03-13 03:24:17 mqtt_io.main [ERROR ] MqttIo crashed! Traceback (most recent call last): File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/modules/init.py", line 51, in install_missing_module_requirements install_missing_requirements(pkgs_required) File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/modules/init.py", line 22, in install_missing_requirements check_call([sys.executable, "-m", "pip", "install"] + pkgs_required) File "/usr/lib/python3.11/subprocess.py", line 413, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/usr/bin/python', '-m', 'pip', 'install', 'Adafruit_DHT']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/main.py", line 107, in main mqtt_gpio.run() File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/server.py", line 1450, in run self._init_sensor_modules() File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/server.py", line 284, in _init_sensor_modules self.sensor_modules[sens_config["name"]] = _init_module( ^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/server.py", line 127, in _init_module install_missing_module_requirements(module) File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/modules/init.py", line 53, in install_missing_module_requirements raise CannotInstallModuleRequirements( mqtt_io.exceptions.CannotInstallModuleRequirements: Unable to install packages for module <module 'mqtt_io.modules.sensor.dht22' from '/home/pi/.local/lib/python3.11/site-packages/mqtt_io/modules/sensor/dht22.py'> (['Adafruit_DHT']): Command '['/usr/bin/python', '-m', 'pip', 'install', 'Adafruit_DHT']' returned non-zero exit status 1. Traceback (most recent call last): File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/modules/init.py", line 51, in install_missing_module_requirements install_missing_requirements(pkgs_required) File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/modules/init.py", line 22, in install_missing_requirements check_call([sys.executable, "-m", "pip", "install"] + pkgs_required) File "/usr/lib/python3.11/subprocess.py", line 413, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/usr/bin/python', '-m', 'pip', 'install', 'Adafruit_DHT']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/main.py", line 115, in main() File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/main.py", line 107, in main mqtt_gpio.run() File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/server.py", line 1450, in run self._init_sensor_modules() File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/server.py", line 284, in _init_sensor_modules self.sensor_modules[sens_config["name"]] = _init_module( ^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/server.py", line 127, in _init_module install_missing_module_requirements(module) File "/home/pi/.local/lib/python3.11/site-packages/mqtt_io/modules/init.py", line 53, in install_missing_module_requirements raise CannotInstallModuleRequirements( mqtt_io.exceptions.CannotInstallModuleRequirements: Unable to install packages for module <module 'mqtt_io.modules.sensor.dht22' from '/home/pi/.local/lib/python3.11/site-packages/mqtt_io/modules/sensor/dht22.py'> (['Adafruit_DHT']): Command '['/usr/bin/python', '-m', 'pip', 'install', 'Adafruit_DHT']' returned non-zero exit status 1.

alexfrench avatar Mar 13 '24 03:03 alexfrench