How do I retrieve the temperature of my CPU using Python? (Assuming I\'m on Linux)
Depending on your Linux distro, you may find a file under /proc
that contains this information. For example, this page suggests /proc/acpi/thermal_zone/THM/temperature
.
Sysmon works nice. Nicely made, it does much more than measure CPU temperature. It is a command line program, and logs all the data it measured to a file. Also, it is open-source and written in python 2.7.
Sysmon: https://github.com/calthecoder/sysmon-1.0.1
If your Linux supports ACPI, reading pseudo-file /proc/acpi/thermal_zone/THM0/temperature
(the path may differ, I know it's /proc/acpi/thermal_zone/THRM/temperature
in some systems) should do it. But I don't think there's a way that works in every Linux system in the world, so you'll have to be more specific about exactly what Linux you have!-)
As an alternative you can install the lm-sensors package, then install PySensors (a python binding for libsensors).