Python wmi c.Win32_PerfFormattedData_PerfOS_Processor win7 error

柔情痞子 提交于 2019-12-13 04:08:33

问题


>>> for i in c.Win32_PerfFormattedData_PerfOS_Processor():
...    print i
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\work\pythonsv\vendor\wmi.py", line 1029, in __getattr__
    return getattr (self._namespace, attribute)
  File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 496, in
__getattr__
    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: <unknown>.Win32_PerfFormattedData_PerfOS_Processor

Anyone could explain this traceback? Made a remote call on WIN7 machine.


回答1:


AttributeError means that the object c doesn't have an attribute Win32_PerfFormattedData_PerfOS_Processor.

The "" indicates that Python asked c to describe itself and c returned the string "" (which obviously isn't terribly helpful). It appears you've created c, so it would illuminate the problem more if you would include the code that created c.

My best guess is that c is some sort of WMI wrapper, but that WMI object doesn't have the Win32_PerfFormattedData_PerfOS_Processor function/method/attribute.

The underlying cause is that either you're not using c as designed (maybe you're missing some run-time components) or c isn't initialized properly.




回答2:


UPDATE:

this worked: i.e. at cmd --> lodctr /q

[link] http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/perfmon-problems-unable-to-add-counters/e90f231d-0014-457d-8b1f-5f342971597a



来源:https://stackoverflow.com/questions/5076755/python-wmi-c-win32-perfformatteddata-perfos-processor-win7-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!