Trouble installing Adafruit's DHT11 Python library

喜你入骨 提交于 2019-12-13 20:22:17

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/50864254/trouble-installing-adafruits-dht11-python-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!