I try to get free memory and swap amounts on Windows 7 64bit machine with psutil python module. Virtual memory info works normally, but getting swap information failed:
Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import psutil
>>> psutil.virtual_memory()
svmem(total=8379674624, available=3433517056, percent=59.0, used=4946157568, free=3433517056)
>>> psutil.swap_memory()
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
psutil.swap_memory()
File "C:\Users\Artem\AppData\Local\Programs\Python\Python38\lib\site-packages\psutil\__init__.py", line 2051, in swap_memory
return _psplatform.swap_memory()
File "C:\Users\Artem\AppData\Local\Programs\Python\Python38\lib\site-packages\psutil\_pswindows.py", line 243, in swap_memory
percentswap = cext.swap_percent()
RuntimeError: PdhAddEnglishCounterW failed. Performance counters may be disabled.
>>>
Module version:
C:\Users\Artem\Documents>pip list
Package Version
---------- -------
pip 25.0.1
psutil 7.1.2
setuptools 49.2.1