3
votes

I am using a Raspberry Pi Zero W where I connected a DHT11 Sensor from Adafruit. While setting up my Raspberry Pi I tried to install miniconda3 to manage my python packages. Somehow I could not install miniconda3 (I guess miniconda3 is not supported on the Raspberry Pi Zero W). However, I managed to install berryconda3. To read the data from my sensor I installed the Adafruit_DHT library (in python2 and python3). I am able to read the data from my sensor in python2 but I am not able to read it in python3. When importing the library with

import Adafruit_DHT

it always shows the following error message: No module named 'Adafruit_DHT'.

For the istallation in python3, I downloaded the Adafruit_Python_DHT library from github.com/adafruit/Adafruit_Python_DHT, copied it to my raspberry and installed it with sudo python3 setup.py install --force-pi. When I try to install it using pip3 install Adafruit_DHT the console replies: pip3: command not found. When using pip install Adafruit_DHT the console replies: "Collecting Adafruit_DHT Could not find a version that satisfies the requirement Adafruit_DHT (from versions: ) No matching distribution found for Adafruit_DHT"

When I try to locate the library I found the following three potential locations where the module should be installed:

~/berryconda3/lib/python3.6/ --> no Adafruit-directory in this location

/usr/local/lib/python3.5/dist-packages --> directory Adafruit_DHT-1.3.2-py3.5-linux-armv61.egg

/usr/local/lib/python2.7/dist-packages --> directory Adafruit_DHT-1.3.2-py2.7-linux-armv61.egg

the command which python3 returns the following information:

/home/pi/berryconda3/bin/python3

When running the command pip3 freeze in /home/pi/berryconda3/bin/python3 it doesn't work (reply: -bash: pip3: command not found). But pip freeze works. I run the command in /home/pi/berryconda3/bin and it got a list with all other libraries I installed (those libraries listed here all work in my scripts). But Adafruit_DHT is not listed.

I guess the problem is the following: When calling python2 the script is looking in the folder /usr/local/lib/python2.7/dist-packages for the Adafruit_DHT library and can find it. When I call python3 the script is looking in the folder ~/berryconda3/lib/python3.6 for the Adafruit_DHT library (because I installed berryconda3). Would it look in the /usr/local/lib/python3.5/dist-packages it should be able to find it.

The question now is how can I get the package installed in /home/pi/berryconda3/bin/python3?

I tried to copy the Adafruit_DHT-1.3.2-py3.5-linux-armv61.egg from /usr/local/lib/python3.5/dist-packages to ~/berryconda3/lib/python3.6/

sudo mv Adafruit_DHT-1.3.2-py3.5-linux-armv6l.egg  ~/berryconda3/lib/python3.6/Adafruit_DHT-1.3.2-py3.5-linux-armv61.egg

After copying it I still get the same error.

I also tried to install the package Adafruit_Python_DHT which I downloaded from github with the following command:

sudo python3 setup.py install --install scripts=~/berryconda3/bin/lib/python3.6/site-packages

The installation run successfully but my script still cannot find the library.

If I try to run "pip install Adafruit_Python_DHT" in ~/berryconda3/bin the output is: Collecting Adafruit_Python_DHT Using cached Adafruit_Python_DHT-1.1.2.tar.gz Complete output from command python setup.py egg_info: [....] import platform_detect ModuleNotFoundError: No module named 'platform_detect'. According to a post found here: https://github.com/adafruit/Adafruit_Python_DHT/pull/67, the Adafruit_Python_DHT library listed in pip does not work yet. So that seems to be the reason why I cannot install it with pip...

I spent at least 10 hours looking online for a solution and de- and reinstalled the Adafruit library using python3 as suggested on a lot of websites but it still doesn't work. Any idea?

2
Can you show how did you install Adafruit_DHT for python3? Was it ‘pip3 install Adafruit_DHT’?dkato
I downloaded the python library from github.com/adafruit/Adafruit_Python_DHT, copied it to my raspberry and installed it with sudo python3 setup.py install --force-pi. When I try to install it using pip3 install Adafruit_DHT the console replies: pip3: command not found. When using pip install Adafruit_DHT the console replies: "Collecting Adafruit_DHT Could not find a version that satisfies the requirement Adafruit_DHT (from versions: ) No matching distribution found for Adafruit_DHT"Heyufan
Thanks. The reason you failed the pip is that the library is not registered to PyPI (pypi.python.org/pypi). It’s quite reasonable.dkato
Can you check the python3’s location by something like ‘which python3’?dkato
which python3 --> /home/pi/berryconda3/bin/python3Heyufan

2 Answers

1
votes

I was having trouble with this and tried to find the answer here. I ended up using the command python3 instead of python and it no longer stopped at the command "import Adafruit_DHT"

0
votes

After downloading the git repository https://github.com/adafruit/Adafruit_Python_DHT

I had to first go into Adafruit_Python_DHT then python setup.py install

Step 1: clone Adafruit https://github.com/adafruit/Adafruit_Python_DHT

Step2: Get into the Adafruit_Python_DHT directory cd Adafruit_Python_DHT

Step 3 (add below in command line) python setup.py install