0

does anyone have an idea why psutil's cpu_freq() returns empty? I'm running python 3.4 on Debian linux 8.7.1. I've tried with and without elevated rights and gotten the same result.

Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.cpu_freq()
[]
>>> 

Other CPU information (such as cpu_stats() is returned correctly. Thanks a lot!

culicidae
  • 61
  • 1
  • 4
  • Does the path `/sys/devices/system/cpu/cpufreq` exist on your system? If so, are there `policy*` directories in there with `scaling_*_freq` files? – Martijn Pieters Mar 23 '17 at 15:11
  • On a Debian server of mine, there are no `policy*` directories, so no frequency information is available to psutil. – Martijn Pieters Mar 23 '17 at 15:14

3 Answers3

0

This is a bug in psutil, see issue #981 in the psutil project issue tracker.

The location of the CPU frequency information has moved in recent kernels, from /sys/devices/system/cpu/cpufreq/platform* directories, to /sys/devices/system/cpu/cpu*/cpufreq directories, and the project has not yet followed suit.

The new 5.2.1 release includes the fix for this.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
0

This was a bug which just fixed in psutil. version: 5.2.1.


Nothing to do with python version or code.

Trying to import cpu_freq from psutil (latest - 5.1.3) on Linux systems fails. The function does not get defined because there is no /sys/devices/system/cpu/cpufreq on the system (as per this line https://github.com/giampaolo/psutil/blob/76d1fb61c14d286aa645f154f4a2b7a7bae8a828/psutil/_pslinux.py#L639)

There is, however, /sys/devices/system/cpu/cpu0/cpufreq(and for cpu1, cpu2..)

On Ubuntu 16.04 (My machine at least), there is /sys/devices/system/cpu/cpufreq but it is empty. therefore cpu_freq() just returns an empty list, like inyour case.

nivhanin
  • 1,688
  • 3
  • 19
  • 31
0

This was a bug which I've just fixed in psutil.

Giampaolo Rodolà
  • 12,488
  • 6
  • 68
  • 60