4

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?

Heyufan
  • 41
  • 1
  • 4
  • Can you show how did you install Adafruit_DHT for python3? Was it ‘pip3 install Adafruit_DHT’? – dkato Jan 27 '18 at 13:27
  • I downloaded the python library from https://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 Jan 27 '18 at 13:44
  • Thanks. The reason you failed the pip is that the library is not registered to PyPI (https://pypi.python.org/pypi). It’s quite reasonable. – dkato Jan 27 '18 at 13:56
  • Can you check the python3’s location by something like ‘which python3’? – dkato Jan 27 '18 at 13:57
  • which python3 --> /home/pi/berryconda3/bin/python3 – Heyufan Jan 27 '18 at 14:05
  • I believe pip3 is located almost same directory. If so, then can you check ‘pip3 freeze’? It shows an available library list. Is the library in the list? – dkato Jan 27 '18 at 14:11
  • pip3 freeze 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 listed here all work). But Adafruit_DHT is not listed here – Heyufan Jan 27 '18 at 14:21
  • 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' – Heyufan Jan 27 '18 at 14:24
  • Delete any instance of the Adafruit_DHT folder on your machine and re-clone it from Git. After, make sure you cd into the new directory and use SUDO to install it. `sudo python setup.py install` Note that the python3 declaration is not needed. Also, there's no need to copy/paste the directory. Just cd to any directory you want and run `git clone https://github.com/adafruit/Adafruit_Python_DHT.git` – Brandon Miller Jan 29 '18 at 15:58
  • @BrandonMiller: Just now I deleted any instances of the Adafruit_DHT folder (using `find -name Ada\*` and `sudo rm -rf`). Then I used `git clone https://github.com/adafruit/Adafruit_Python_DHT.git` to copy it to the `~/berryconda3/lib/python3.6/` folder. After that I used `sudo python setup.py install` to install it. Same result. Python3 can't find the library. Python2 runs smoothly... – Heyufan Mar 03 '18 at 11:13

2 Answers2

1

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

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