question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'Sensor' from 'w1thermsensor'

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
a-spcommented, Jan 30, 2021

It worked. Thank you for taking the time to answer silly question and for your advice! 😊

2reactions
bsimmocommented, Jan 30, 2021

@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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found