Getting CPU temperature using Python?

后端 未结 10 1149
失恋的感觉
失恋的感觉 2020-12-03 05:08

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

相关标签:
10条回答
  • 2020-12-03 05:30

    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.

    0 讨论(0)
  • 2020-12-03 05:31

    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

    0 讨论(0)
  • 2020-12-03 05:34

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

    0 讨论(0)
  • 2020-12-03 05:37

    As an alternative you can install the lm-sensors package, then install PySensors (a python binding for libsensors).

    0 讨论(0)
提交回复
热议问题