Anyone using a Python script to monitor CPU usage on a Windows machine ? i've google for some time but have not been able to find any usable script. could you guys show me some example of what you're using ?

Here is the errors i got.

    Traceback (most recent call last):
  File "test.py", line 1, in 
    import wmi
  File "c:\Python26\lib\site-packages\wmi.py", line 141, in 
    from win32com.client import GetObject, Dispatch
ImportError: No module named win32com.client
  • Did you install pywin32? – Alex J Jun 7 '09 at 14:34
  • howdy, i installed win32 on another machine and it works like a charm. for my developing app i decided to use perl instead, since the ActivePerl package installer is very easy to use, and permits me to search and add what pachets i do need – s.mihai Jun 8 '09 at 4:51

Us psutil module, it provides for memory, cpu, netowrk, etc usages. Visit their project webpage http://code.google.com/p/psutil/ .


Lucky ol' you gets to dig around in WMI. Check out the Python module 'wmi' which is about as good as I've seen.

  • i tried that one, i just wasn't able to get that module installed, and i thought there was some other way to achieve this task. – s.mihai Jun 7 '09 at 12:45
  • What errors did you get? – Alex J Jun 7 '09 at 13:27
  • i updated the question. – s.mihai Jun 7 '09 at 13:49

You are missing the python win32 extensions which you can find here.


This blog entry shows some code:

def get_cpu_load():
    """ Returns a list CPU Loads"""
    result = []
    cmd = "WMIC CPU GET LoadPercentage "
    response = os.popen(cmd + ' 2>&1','r').read().strip().split("\r\n")
    for load in response[1:]:
    return result

if __name__ == '__main__':
    print get_cpu_load()

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.