1
votes

My Python 3 script uses psutil v5.6.2 to extract various information about the current system (Ubuntu 18.04, AMD Ryzen 2700X) such as the CPU core temperatures.

Problem: However running the following code to obtain the core temperatures

import psutil
psutil.sensors_temperatures()

returns an empty dict

{}

even though running lmsensors (sensors version 3.4.0 with libsensors version 3.4.0, Ubuntu 18.04) does return the temperatures

$ sensors
nouveau-pci-1f00
Adapter: PCI adapter
GPU core:     +0.91 V  (min =  +0.80 V, max =  +1.19 V)
temp1:        +36.0°C  (high = +95.0°C, hyst =  +3.0°C)
                       (crit = +105.0°C, hyst =  +5.0°C)
                       (emerg = +135.0°C, hyst =  +5.0°C)

k10temp-pci-00c3
Adapter: PCI adapter
Tdie:         +79.4°C  (high = +70.0°C)
Tctl:         +89.4°C

Why is psutil not giving us the temperatures we need, and how can we solve this problem?

PS: Also looked into Pysensors but it does not support Python 3. Any suggestions on a Python 3 alternative?

1
Which version are you using of psutil, it gives me module 'psutil' has no attribute 'sensors_temperatures' for v5.6.3 - Devesh Kumar Singh
@JainilPatel I am running psutil in Linux (Ubuntu 18.04) - Nyxynyx
@DeveshKumarSingh I am using v5.6.2. This function can be found in the docs psutil.readthedocs.io/en/latest/#psutil.sensors_temperatures - Nyxynyx
@JainilPatel Ubuntu is considered a Unix based system, so I think it should work? The link to the sensors_temperatures function in the docs specifically stated Availability: Linux, FreeBSD - Nyxynyx
Looking briefly at both projects I think psutil reads temperatures from /sys/class/hwmon/hwmon... while lm sensors reads directly from chips. - VPfB

1 Answers

1
votes

Pysensors does support python3 as of now