Accessing CPU temperature in python

rectangletangle picture rectangletangle · Jul 16, 2010 · Viewed 47k times · Source

I need an example code for accessing CPU temperature in python.

I'm running windows 7, BTW.

Answer

eadmaster picture eadmaster · Sep 29, 2015

Use the WMI module + Open Hardware Monitor + its WMI interface described here.

Sample code:

import wmi
w = wmi.WMI(namespace="root\OpenHardwareMonitor")
temperature_infos = w.Sensor()
for sensor in temperature_infos:
    if sensor.SensorType==u'Temperature':
        print(sensor.Name)
        print(sensor.Value)