Getting CPU temperature using Python?

jamieb picture jamieb · Mar 14, 2010 · Viewed 48.8k times · Source

How do I retrieve the temperature of my CPU using Python? (Assuming I'm on Linux)

Answer

Craig McQueen picture Craig McQueen · Mar 5, 2013

There is a newer "sysfs thermal zone" API (see also LWN article and Linux kernel doc) showing temperatures under e.g.

/sys/class/thermal/thermal_zone0/temp

Readings are in thousandths of degrees Celcius (although in older kernels, it may have just been degrees C).