ImportError: No module named Adafruit_DHT

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
FooLingYu2
 
Posts: 3
Joined: Thu Oct 16, 2014 2:12 pm

ImportError: No module named Adafruit_DHT

Post by FooLingYu2 »

Hello Adafruit Community!

So I've properly attached DHT22 Humidity Sensor to my BeagleBone Black Rev C. I'm running OS BANNED on my MacBook Pro and I followed the directions provided by Adafruit on how to get my DHT22 working.

Code: Select all

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

cd Adafruit_Python_DHT

sudo apt-get upgrade

sudo apt-get install build-essential python-dev

sudo python setup.py install

cd examples

sudo ./AdafruitDHT.py 22 P8_11

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

No problems prior to sudo ./AdafruitDHT.py 22 P8_11

Any idea why this module can't be found? I did an ls while in the Adafruit_Python_DHT directory and sure enough Adafruit_DHT was there. Any help is very much appreciated! Thank you for your time in advanced :)

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: ImportError: No module named Adafruit_DHT

Post by tdicola »

Can you go back to the Adafruit_Python_DHT directory root (that has the setup.py script) and run this command to force it to reinstall, and copy the output of it to paste back in the thread here:

Code: Select all

sudo python setup.py install --force
Lets see if perhaps there's some issue with Python installing the library so it can be found by other programs.

User avatar
FooLingYu2
 
Posts: 3
Joined: Thu Oct 16, 2014 2:12 pm

Re: ImportError: No module named Adafruit_DHT

Post by FooLingYu2 »

Problem fixed! Thank you so much! You are my savior. For the past 2 weeks, I have been doing intense research trying to find out what the problem was. I can't thank you enough

Code: Select all

root@beaglebone:~# cd Adafruit_Python_DHT
root@beaglebone:~/Adafruit_Python_DHT# sudo python setup.py install --force
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-4.0.1.zip
Extracting in /tmp/tmpuDvt4C
Now working in /tmp/tmpuDvt4C/setuptools-4.0.1
Building a Setuptools egg in /root/Adafruit_Python_DHT
/root/Adafruit_Python_DHT/setuptools-4.0.1-py2.7.egg
running install
running bdist_egg
running egg_info
creating Adafruit_DHT.egg-info
writing Adafruit_DHT.egg-info/PKG-INFO
writing top-level names to Adafruit_DHT.egg-info/top_level.txt
writing dependency_links to Adafruit_DHT.egg-info/dependency_links.txt
writing manifest file 'Adafruit_DHT.egg-info/SOURCES.txt'
reading manifest file 'Adafruit_DHT.egg-info/SOURCES.txt'
writing manifest file 'Adafruit_DHT.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/Adafruit_DHT
copying Adafruit_DHT/__init__.py -> build/lib.linux-armv7l-2.7/Adafruit_DHT
copying Adafruit_DHT/Beaglebone_Black.py -> build/lib.linux-armv7l-2.7/Adafruit_DHT
copying Adafruit_DHT/Test.py -> build/lib.linux-armv7l-2.7/Adafruit_DHT
copying Adafruit_DHT/common.py -> build/lib.linux-armv7l-2.7/Adafruit_DHT
copying Adafruit_DHT/Raspberry_Pi.py -> build/lib.linux-armv7l-2.7/Adafruit_DHT
copying Adafruit_DHT/platform_detect.py -> build/lib.linux-armv7l-2.7/Adafruit_DHT
running build_ext
building 'Adafruit_DHT.Beaglebone_Black_Driver' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/source
creating build/temp.linux-armv7l-2.7/source/Beaglebone_Black
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/_Beaglebone_Black_Driver.c -o build/temp.linux-armv7l-2.7/source/_Beaglebone_Black_Driver.o -std=gnu99
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/common_dht_read.c -o build/temp.linux-armv7l-2.7/source/common_dht_read.o -std=gnu99
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/Beaglebone_Black/bbb_dht_read.c -o build/temp.linux-armv7l-2.7/source/Beaglebone_Black/bbb_dht_read.o -std=gnu99
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c source/Beaglebone_Black/bbb_mmio.c -o build/temp.linux-armv7l-2.7/source/Beaglebone_Black/bbb_mmio.o -std=gnu99
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-armv7l-2.7/source/_Beaglebone_Black_Driver.o build/temp.linux-armv7l-2.7/source/common_dht_read.o build/temp.linux-armv7l-2.7/source/Beaglebone_Black/bbb_dht_read.o build/temp.linux-armv7l-2.7/source/Beaglebone_Black/bbb_mmio.o -lrt -o build/lib.linux-armv7l-2.7/Adafruit_DHT/Beaglebone_Black_Driver.so
creating build/bdist.linux-armv7l
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-2.7/Adafruit_DHT/__init__.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-2.7/Adafruit_DHT/Beaglebone_Black.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-2.7/Adafruit_DHT/Test.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-2.7/Adafruit_DHT/common.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-2.7/Adafruit_DHT/Beaglebone_Black_Driver.so -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-2.7/Adafruit_DHT/Raspberry_Pi.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
copying build/lib.linux-armv7l-2.7/Adafruit_DHT/platform_detect.py -> build/bdist.linux-armv7l/egg/Adafruit_DHT
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Beaglebone_Black.py to Beaglebone_Black.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Test.py to Test.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/common.py to common.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Raspberry_Pi.py to Raspberry_Pi.pyc
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/platform_detect.py to platform_detect.pyc
creating stub loader for Adafruit_DHT/Beaglebone_Black_Driver.so
byte-compiling build/bdist.linux-armv7l/egg/Adafruit_DHT/Beaglebone_Black_Driver.py to Beaglebone_Black_Driver.pyc
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_DHT.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_DHT.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_DHT.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_DHT.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
writing build/bdist.linux-armv7l/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/Adafruit_DHT-1.0.0-py2.7-linux-armv7l.egg' and adding 'build/bdist.linux-armv7l/egg' to it
removing 'build/bdist.linux-armv7l/egg' (and everything under it)
Processing setuptools-4.0.1-py2.7.egg
Copying setuptools-4.0.1-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Removing setuptools 3.6 from easy-install.pth file
Adding setuptools 4.0.1 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/setuptools-4.0.1-py2.7.egg
Processing dependencies for setuptools==4.0.1
Finished processing dependencies for setuptools==4.0.1
Processing Adafruit_DHT-1.0.0-py2.7-linux-armv7l.egg
Copying Adafruit_DHT-1.0.0-py2.7-linux-armv7l.egg to /usr/local/lib/python2.7/dist-packages
Adding Adafruit-DHT 1.0.0 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/Adafruit_DHT-1.0.0-py2.7-linux-armv7l.egg
Processing dependencies for Adafruit-DHT==1.0.0
Finished processing dependencies for Adafruit-DHT==1.0.0
root@beaglebone:~/Adafruit_Python_DHT# cd examples/
root@beaglebone:~/Adafruit_Python_DHT/examples# sudo ./AdafruitDHT.py 22 P8_11
Temp=23.3*C  Humidity=53.7%
root@beaglebone:~/Adafruit_Python_DHT/examples# sudo ./AdafruitDHT.py 22 P8_11
Temp=23.2*C  Humidity=53.7%
root@beaglebone:~/Adafruit_Python_DHT/examples# sudo ./AdafruitDHT.py 22 P8_11
Temp=24.5*C  Humidity=75.3%
root@beaglebone:~/Adafruit_Python_DHT/examples# sudo ./AdafruitDHT.py 22 P8_11
Temp=23.5*C  Humidity=59.3%
root@beaglebone:~/Adafruit_Python_DHT/examples# sudo ./AdafruitDHT.py 22 P8_11
Temp=23.4*C  Humidity=59.1%

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: ImportError: No module named Adafruit_DHT

Post by tdicola »

Oh no problem, glad it was a simple fix. Thanks for the followup and good luck with the project!

User avatar
elementFe
 
Posts: 1
Joined: Sun Jan 18, 2015 6:35 pm

Re: ImportError: No module named Adafruit_DHT

Post by elementFe »

Hello there.

I'm having a similar issue, but with a different module. I am attempting to follow https://learn.adafruit.com/character-lc ... lack/usage with a beaglebone black

and receive:

Code: Select all

root@beaglebone:~/Adafruit_Python_CharLCD/examples# python char_lcd.py
Traceback (most recent call last):
  File "char_lcd.py", line 6, in <module>
    import Adafruit_CharLCD as LCD

After attempting to --force the install as suggested in this thread, I have the same error. What comes out after the install is shown below:

Code: Select all

root@beaglebone:~/Adafruit_Python_CharLCD# python setup.py install --force
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-3.5.1.zip
Traceback (most recent call last):
  File "setup.py", line 2, in <module>
    use_setuptools()
  File "/root/Adafruit_Python_CharLCD/ez_setup.py", line 149, in use_setuptools
    return _do_download(version, download_base, to_dir, download_delay)
  File "/root/Adafruit_Python_CharLCD/ez_setup.py", line 107, in _do_download
    to_dir, download_delay)
  File "/root/Adafruit_Python_CharLCD/ez_setup.py", line 287, in download_setuptools
    downloader(url, saveto)
  File "/root/Adafruit_Python_CharLCD/ez_setup.py", line 194, in download_file_curl
    _clean_check(cmd, target)
  File "/root/Adafruit_Python_CharLCD/ez_setup.py", line 157, in _clean_check
    subprocess.check_call(cmd)
  File "/usr/lib/python2.7/subprocess.py", line 511, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['curl', 'https://pypi.python.org/packages/source/s/setuptools/setuptools-3.5.1.zip', '--silent', '--output', '/root/Adafruit_Python_CharLCD/setuptools-3.5.1.zip']' returned non-zero exit status 60
Any suggestions? Thank you so much for your time.

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: ImportError: No module named Adafruit_DHT

Post by tdicola »

Hrm it looks like the setup script can't install setuptools (a python package for installing python modules) because it can't download the file. The error coming from the curl utility is this one:
CURLE_SSL_CACERT (60)

Peer certificate cannot be authenticated with known CA certificates.
A few things to check:
- Make sure the board is connected to the internet.
- Make sure you don't have any proxy or other issues that might be intercepting or changing traffic from the board to the internet.
- Make sure you're running the latest Raspbian image if it's a Pi, or the latest BeagleBone Black Debian image if it's a BBB.
- If all else fails, try to manually install setuptools by running these commands:

Code: Select all

sudo apt-get update
sudo apt-get install python-setuptools
Then try running the 'sudo python setup.py install' command again.

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”