Comments (10)
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.
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.
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):
-
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. -
After the setup, run your .py file in any directory(home or any other) apart from the Adafruit_Python_DHT directory.
(Use the commandcp 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.
I have the same problem. Any plans to support pi 3?
from adafruit_python_dht.
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.
In fact it just my low knowlegde on python.. some related to folders and files locations... :(
from adafruit_python_dht.
@TiagoGouvea How did you manage to resolve this? I am also getting the exact same error.
from adafruit_python_dht.
@TiagoGouvea i also have similar issue, how to solve it?
from adafruit_python_dht.
How exactly do I do this @Cartmanishere ?
from adafruit_python_dht.
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_DriverHere 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)
- pip package looks broken HOT 4
- Installation failure on Windows 10 HOT 2
- hello...I try to install python library of dht11 on raspberry pi but it appear no route to host?what is the problem?please help me... HOT 2
- Semaphore not finding library HOT 4
- Cable Length Causes incorrect DHT11 Readings HOT 6
- import errors in setup.py HOT 1
- unknown platform due to very wrong detection mechanism HOT 1
- Specifiy Raspberry version when using pip3 install Adafruit_DHT HOT 3
- IOError: [Errno 24] Too many open files: '/proc/cpuinfo' HOT 2
- Can't install on RPI3 HOT 1
- Will this work in Ubuntu 16.04 with normal pc HOT 7
- Declare sensor dinamically HOT 2
- DHT22 humidity and temperature values are incorrect HOT 2
- setup.py fails to install with error "TypeError: __init__() takes exactly 2 arguments (4 given)" HOT 4
- Google Authentication Error HOT 1
- I can not install RaspBerry 3 and Raspbian Jessie Lite HOT 10
- Broken link in ez_setup HOT 4
- AdafruitDHT.py show higher temp HOT 2
- Problem witch installing HOT 5
- Failed pip Install of Adafruit_Python_DHT on Raspbian Stretch HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_python_dht.