Psutil: /sys/class/hwmon related files not found (psutil.sensors_temperatures)

Created on 30 Dec 2019  Â·  4Comments  Â·  Source: giampaolo/psutil

Platform

  • OS: Ubuntu 19.10
  • python version: 3.7.5
  • psutil version: 5.5.1 (same problem on 5.6.7)

Bug description
When I run: print(psutil.sensors_temperatures()['coretemp'][0].current) or temperatures script.

Before getting proper output, I'll get following error:

python3 temperatures.py 
/usr/lib/python3/dist-packages/psutil/_pslinux.py:1223: RuntimeWarning: ignoring FileNotFoundError(2, 'No such file or directory') for file '/sys/class/hwmon/hwmon0/temp1_input'
  RuntimeWarning)
/usr/lib/python3/dist-packages/psutil/_pslinux.py:1223: RuntimeWarning: ignoring FileNotFoundError(2, 'No such file or directory') for file '/sys/class/hwmon/hwmon0/temp2_input'
  RuntimeWarning)
/usr/lib/python3/dist-packages/psutil/_pslinux.py:1223: RuntimeWarning: ignoring FileNotFoundError(2, 'No such file or directory') for file '/sys/class/hwmon/hwmon2/temp1_input'
  RuntimeWarning)
/usr/lib/python3/dist-packages/psutil/_pslinux.py:1223: RuntimeWarning: ignoring FileNotFoundError(2, 'No such file or directory') for file '/sys/class/hwmon/hwmon2/temp2_input'
  RuntimeWarning)
/usr/lib/python3/dist-packages/psutil/_pslinux.py:1223: RuntimeWarning: ignoring OSError(6, 'No such device or address') for file '/sys/class/hwmon/hwmon5/temp2_input'
  RuntimeWarning)
/usr/lib/python3/dist-packages/psutil/_pslinux.py:1223: RuntimeWarning: ignoring OSError(6, 'No such device or address') for file '/sys/class/hwmon/hwmon5/temp8_input'
  RuntimeWarning)
acpitz
    acpitz               57.0 °C (high = 128.0 °C, critical = 128.0 °C)

pch_cannonlake
    pch_cannonlake       53.0 °C (high = None °C, critical = None °C)

coretemp
    Package id 0         57.0 °C (high = 100.0 °C, critical = 100.0 °C)
    Core 0               55.0 °C (high = 100.0 °C, critical = 100.0 °C)
    Core 1               55.0 °C (high = 100.0 °C, critical = 100.0 °C)
    Core 2               57.0 °C (high = 100.0 °C, critical = 100.0 °C)
    Core 3               57.0 °C (high = 100.0 °C, critical = 100.0 °C)

thinkpad
    thinkpad             57.0 °C (high = None °C, critical = None °C)
    thinkpad             1.0 °C (high = None °C, critical = None °C)
    thinkpad             66.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)
    thinkpad             0.0 °C (high = None °C, critical = None °C)

iwlwifi
    iwlwifi              49.0 °C (high = None °C, critical = None °C)

Regular output on sensors is as follows:

sensors
iwlwifi-virtual-0
Adapter: Virtual device
temp1:        +51.0°C  

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +58.0°C  (high = +100.0°C, crit = +100.0°C)
Core 0:        +56.0°C  (high = +100.0°C, crit = +100.0°C)
Core 1:        +56.0°C  (high = +100.0°C, crit = +100.0°C)
Core 2:        +56.0°C  (high = +100.0°C, crit = +100.0°C)
Core 3:        +57.0°C  (high = +100.0°C, crit = +100.0°C)

BAT0-acpi-0
Adapter: ACPI interface
in0:         +17.45 V  

thinkpad-isa-0000
Adapter: ISA adapter
fan1:           0 RPM
temp1:        +59.0°C  
temp2:            N/A  
temp3:         +0.0°C  
temp4:         +0.0°C  
temp5:         +0.0°C  
temp6:         +0.0°C  
temp7:         +0.0°C  
temp8:            N/A  
temp9:         +0.0°C  
temp10:        +1.0°C  
temp11:       +66.0°C  
temp12:        +0.0°C  
temp13:        +0.0°C  
temp14:        +0.0°C  
temp15:        +0.0°C  
temp16:        +0.0°C  

pch_cannonlake-virtual-0
Adapter: Virtual device
temp1:        +53.0°C  

acpitz-acpi-0
Adapter: ACPI interface
temp1:        +59.0°C  (crit = +128.0°C)

I looked at other issues with similar problem, but nothing seems to resolve my issue. Please let me know if you have any idea how to resolve this.

bug linux

All 4 comments

Related issue from s-tui https://github.com/amanusk/s-tui/issues/135
It appears the cause of the problem is a change to the /sys/class/hwmon/ directory and introduction of new sensors in new Linux kernels >= 5.3.

There are now some sub directories with /sys/class/hwmon/hwmon*/temp*_label, but no corresponding /sys/class/hwmon/hwmon*/temp*_input
Thus a runtime warning is emitted here: https://github.com/giampaolo/psutil/blob/253abf3fc61ccc3ab1031a9b430a7e99e2194107/psutil/_pslinux.py#L1227

Sometimes the actual readout is done from a different file, such as /sys/class/hwmon/hwmon1/in0_input, but I am not certain of the consistency of this.

Right as it turns out it's an issue introduced with 5.3 kernel.

Until this issue is fixed, I'll resort to use:

import warnings
warnings.filterwarnings("ignore")

in my code to hide the warnings and get clean output.

I think it makes sense to avoid emitting the warning. I turned that into a debug message instead (can be enabled by setting PSUTIL_DEBUG=1 env var). The C extensions already rely on PSUTIL_DEBUG in many places. This was never documented though (it probably should).

Right as it turns out it's an issue introduced with 5.3 kernel.

Until this issue is fixed, I'll resort to use:

import warnings
warnings.filterwarnings("ignore")

in my code to hide the warnings and get clean output.

Cool, That's precisely what I am looking for

Was this page helpful?
0 / 5 - 0 ratings