views:

450

answers:

4

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

+1  A: 

Py-cputemp at http://sourceforge.net/projects/py-cputemp/ seems to do the job.

DrDee
py-cputemp is basically a thin veneer over /proc/acpi/thermal_zone. This originally didn't work for me until I realized that I needed to enable ACPI in my BIOS. I had disabled it because I figured I didn't want power management on a server. Thanks for the answer; I'm accepting this one because it was posted first and lead me to think about the source of my problem.
jamieb
+1  A: 

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.

Greg Hewgill
A: 

You could try the PyI2C module, it can read directly from the kernel.

WoLpH
+2  A: 

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!-)

Alex Martelli