0

I'm having a Raspberry Pi 4 model B with 32-biy OS

I have tried to use this command to install 'Adafruit_DHT' on my Raspberry pi 4 model B :

git clone https://github.com/adafruit/Adafruit_Python_DHT.git 

cd Adafruit_Python_DHT 

sudo apt-get install build-essential python-dev 

sudo python setup.py install

The below message shows the Adafruit_DHT is installed successfully :

Installed /usr/lib/python3.9/site-packages/Adafruit_DHT-1.4.0-py3.9-linux-armv7l.egg Processing dependencies for Adafruit-DHT==1.4.0 Finished processing dependencies for Adafruit-DHT==1.4.0

But when I run my dht program, it still shows :

"Traceback (most recent call last): File "/home/asdf/Desktop/dht.py", line 4, in import Adafruit_DHT ModuleNotFoundError: No module named 'Adafruit_DHT' "

DHT.py :

import time
from pyrebase import pyrebase
from board import *
import Adafruit_DHT

DHT_PIN = 2
DHT_SENSOR = Adafruit_DHT.DHT11
config = {
    #firebase config
    "apiKey":"MY API KEY",
    "authDomain":"authdomain",
    "databaseURL":"databaseURL",
    "projectId":"projectId",
    "storageBucket":"...", "..."
}
firebase=pyrebase.initialize_app(config)
db=firebase.database()
while True:
    humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN)
    data = {
    "temperature":temperature,
    "humidity":humidity
    }   
    db.child("DHT").push(data)
    time.sleep(3)

Please help me to fix the issue, I'm new to raspberry pi, I have tried google, stack overflow, YouTube solutions for 2 weeks to try to solve it, but none of it works...

  • Do you also run your python script using `sudo` ? It might be that the `Adafruit_DHT` library is only installed for the root user. – Paolo Sini Aug 22 '23 at 12:26

1 Answers1

0

Try running the script through the terminal while using sudo. so open cmd and cd into the directory with the dht file

sudo python DHT.py

Could be a permissions issue though im not entirely sure hope the issue gets resolved.

Trynabal
  • 21
  • 3