os: windows professional
I try to use psutil to get a list of processes and use them in cpu, I ran the script as an administrator, and it fails when it encounters the DymoPnpService.exe process, what could be the problem?
import psutil def process(): plist = psutil.get_process_list() plist = sorted(plist, key=lambda i: i.name) for i in plist: print i.name, i.get_cpu_percent() def main(): process() main()
AcroRd32.exe 0.0 AcroRd32.exe 0.0 DymoPnpService.exe
Traceback (most recent call last): File "C:\Users\krisdigitx\Documents\windowsutil.py", line 13, in <module> main() File "C:\Users\krisdigitx\Documents\windowsutil.py", line 10, in main process() File "C:\Users\krisdigitx\Documents\windowsutil.py", line 7, in process print i.name, i.get_cpu_percent() File "C:\Python27\lib\site-packages\psutil\__init__.py", line 330, in get_cpu_percent pt1 = self._platform_impl.get_cpu_times() File "C:\Python27\lib\site-packages\psutil\_psmswindows.py", line 125, in wrapper raise AccessDenied(self.pid, self._process_name) AccessDenied: (pid=1832, name='DymoPnpService.exe')
more research:
strange, I can run the program from the Windows command line ... but it does not work in the style of python ide
source share