Giter Club home page Giter Club logo

Comments (10)

Cartmanishere avatar Cartmanishere commented on September 13, 2024 34

For anyone else facing the same issue that @TiagoGouvea mentioned.
Try to run your program from outside the Adafruit_DHT directory that was cloned.
It happens because when you run -
import Adafruit_DHT
It imports the Adafruit_DHT folder in your current directory instead of the one installed in your site-packages directory.
When run from anywhere else, it is working fine.
Hope this helped.

from adafruit_python_dht.

TiagoGouvea avatar TiagoGouvea commented on September 13, 2024 3

I'm getting on raspberry pi 3:

  File "dht11_test.py", line 21, in <module>
    umid, temp = Adafruit_DHT.read_retry(sensor, pino_sensor);
  File "/home/pi/scripts/Adafruit_DHT/common.py", line 92, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "/home/pi/scripts/Adafruit_DHT/common.py", line 78, in read
    platform = get_platform()
  File "/home/pi/scripts/Adafruit_DHT/common.py", line 53, in get_platform
    from . import Raspberry_Pi_2
  File "/home/pi/scripts/Adafruit_DHT/Raspberry_Pi_2.py", line 22, in <module>
    from . import Raspberry_Pi_2_Driver as driver
ImportError: cannot import name Raspberry_Pi_2_Driver````

even using --force-pi2 on setup

from adafruit_python_dht.

teerna avatar teerna commented on September 13, 2024 2

I got the same error in my R Pi 3 and I found a fix for it after some research.

So for those getting an error such as this one:
Traceback (most recent call last):
File "simpletest.py", line 39, in
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
File "/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py", line 94, in read_retry
humidity, temperature = read(sensor, pin, platform)
File "/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py", line 80, in read
platform = get_platform()
File "/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py", line 55, in get_platform
from . import Raspberry_Pi_2
File "/home/pi/Adafruit_Python_DHT/Adafruit_DHT/Raspberry_Pi_2.py", line 22, in
from . import Raspberry_Pi_2_Driver as driver
ImportError: cannot import name Raspberry_Pi_2_Driver

Here is the fix(as per a comment by Mr Bogd):

  1. Use sudo python3 setup.py install during the setup installation as you are more likely to be running Python 2 but the codes require Python 3.

  2. After the setup, run your .py file in any directory(home or any other) apart from the Adafruit_Python_DHT directory.
    (Use the command cp yourpythonfilename.py yourdirectoryname/ to copy the file to your desired directory where yourpythonfilename is the name of your python file and yourdirectoryname is the name of your directory you wish to copy the file to).
    This is because the python file imports the Adafruit_DHT directory(through this line: import Adafruit_DHT) so it should not be in the same directory.

from adafruit_python_dht.

JockeNasvall avatar JockeNasvall commented on September 13, 2024

I have the same problem. Any plans to support pi 3?

from adafruit_python_dht.

tdicola avatar tdicola commented on September 13, 2024

Hrm I can't repro any issues on the Pi 3, just tried reading an AM2302 and it works great with the current lib and the latest Raspbian Jessie. Try installing a fresh SD card image and the library again to check there isn't something else going on.

Also make sure you don't have a lot of CPU intensive things running in the background. The library works by trying to very quickly read the output of the sensor but it can get tripped up if the kernel is interrupting it to let processor intensive tasks run.

And one last little thing to check is how you're powering the device. Give it 3.3V power from the Pi instead of 5V power--the signal line has a pull-up resistor so you don't want to have it pull up to 5V and then feed that into an input on the Pi.

from adafruit_python_dht.

TiagoGouvea avatar TiagoGouvea commented on September 13, 2024

In fact it just my low knowlegde on python.. some related to folders and files locations... :(

from adafruit_python_dht.

deepakkusahoo avatar deepakkusahoo commented on September 13, 2024

@TiagoGouvea How did you manage to resolve this? I am also getting the exact same error.

from adafruit_python_dht.

manfye avatar manfye commented on September 13, 2024

@TiagoGouvea i also have similar issue, how to solve it?

from adafruit_python_dht.

Lynexo avatar Lynexo commented on September 13, 2024

How exactly do I do this @Cartmanishere ?

from adafruit_python_dht.

edgarbc avatar edgarbc commented on September 13, 2024

Thank you! This worked for me.

I got the same error in my R Pi 3 and I found a fix for it after some research.

So for those getting an error such as this one:
Traceback (most recent call last):
File "simpletest.py", line 39, in
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
File "/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py", line 94, in read_retry
humidity, temperature = read(sensor, pin, platform)
File "/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py", line 80, in read
platform = get_platform()
File "/home/pi/Adafruit_Python_DHT/Adafruit_DHT/common.py", line 55, in get_platform
from . import Raspberry_Pi_2
File "/home/pi/Adafruit_Python_DHT/Adafruit_DHT/Raspberry_Pi_2.py", line 22, in
from . import Raspberry_Pi_2_Driver as driver
ImportError: cannot import name Raspberry_Pi_2_Driver

Here is the fix(as per a comment by Mr Bogd):

1. Use `sudo python3 setup.py` install during the setup installation as you are more likely to be running Python 2 but the codes require Python 3.

2. After the setup, run your .py file in any directory(home or any other) apart from the Adafruit_Python_DHT directory.
   (Use the command `cp yourpythonfilename.py yourdirectoryname/` to copy the file to your desired directory where yourpythonfilename is the name of your python file and yourdirectoryname is the name of your directory you wish to copy the file to).
   This is because the python file imports the Adafruit_DHT directory(through this line: `import Adafruit_DHT`) so it should not be in the same directory.

from adafruit_python_dht.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.