简体   繁体   中英

Trouble installing Adafruit's DHT11 Python library

I followed these instructions to install the Adafruit DHT11 library ( https://github.com/adafruit/Adafruit_Python_DHT ):

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

And I found the library installed under /home/pi (I'm working with a Raspberry Pi 3 ). The file I want to fun is in /home/pi/Desktop so I move the library into that directory. However, I still can't run my python file properly. This is the error I'm getting:

Traceback (most recent call last): 
   File "sensorRead.py", line 4, in <module>
      import Adafruit_DHT
ImportError: No module named 'Adafruit_DHT'

How do I get rid of this error? And where should I move my file (or the library) so the library will work? Thank you.

I fixed it. I moved my file into Adafruit_Python_DHT/examples and ran it with the python sensorRead.py command. To be honest, I don't know why it works when I put it into examples, but it does.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM