ImportError: cannot import name 'Sensor' from 'w1thermsensor'
See original GitHub issueDescribe the bug Hello, when I try to run a simple code (see code below) I receive this error:
Traceback (most recent call last):
File "temperature.py", line 1, in <module>
from w1thermsensor import W1ThermSensor, Sensor
ImportError: cannot import name 'Sensor' from 'w1thermsensor' (/usr/lib/python3/dist-packages/w1thermsensor/__init__.py)
Environment and Version
- OS (incl. distribution and version): Raspbian (10 Buster)
- Python Version: 3.7.3
- w1thermsensor Version (
w1thermsensor --version
): 2.0.0 - If applicable: DS18B20 wired to a Raspberry Pi 3 B+
To Reproduce
w1thermsensor installed via sudo apt-get install python3-w1thermsensor
simple test code:
from w1thermsensor import W1ThermSensor, Sensor
sensor = W1ThermSensor(Sensor.DS18B20, "3c01b55615b0")
sensor.set_resolution(9)
temperature_in_celsius = sensor.get_temperature()
print(temperature_in_celsius)
What am I missing? Thank you!
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
ImportError: cannot import name Sensor · Issue #97 - GitHub
Hello, I've just installed the code according to the guide and without any problems on an updated Raspian and the program manages to...
Read more >w1thermsensor - PyPI
Get the temperature from your w1 therm sensor in a single line of code! ... of this package you might get the following...
Read more >Raspberry Pi 3 + DS18B20 + Python problems
import time from w1thermsensor import W1ThermSensor sensor ... w1thermsensor import W1ThermSensor ImportError: No module named w1thermsensor.
Read more >timofurrer/w1thermsensor - Gitter
I have 2 temp sensors, and i used the code above to read these sensors. But i want the temp value in a...
Read more >DS18B20, W1ThermSensor, Raspberry pi Zero W, and ...
SensorNotReadyError ; Returns no value in the temp_c property after ... sudo python3 >>> from w1thermsensor import W1ThermSensor, Sensor ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It worked. Thank you for taking the time to answer silly question and for your advice! 😊
@timofurrer my bad, I’m not up with the just released v2. Must have a go and also use the asyncio too (perhaps put something in the docs why and when it should be used it, other than to replace my fudged threading for reading the sensors.) thanks 😃