Skip to content

[Windows] "PdhAddEnglishCounterW failed" when getting swap memory info #2681

@artem78

Description

@artem78

Summary

  • OS: Windows 7 64bit
  • Architecture: 64bit
  • Psutil version: 5.9.5 - 7.1.3
  • Python version: 3.8.20 (latest with W7 support)
  • Type: core

Description

I know my system is outdated, but I hope anybody can fix this problem.

Sample code for demonstrate problem:

>>> import psutil
>>> psutil.swap_memory()
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    psutil.swap_memory()
  File "C:\Users\Artem\AppData\Local\Programs\Python\Python38\lib\site-packages\psutil\__init__.py", line 1992, in swap_memory
    return _psplatform.swap_memory()
  File "C:\Users\Artem\AppData\Local\Programs\Python\Python38\lib\site-packages\psutil\_pswindows.py", line 257, in swap_memory
    percentswap = cext.swap_percent()
RuntimeError: PdhAddEnglishCounterW failed. Performance counters may be disabled.

I checked different psutils versions and this problem first appeared in 5.9.5 version and still exists in latest version.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions