I'm trying to run this code and I'm not getting the list of processes by name:
import psutil
PROCNAME = "python.exe"
for proc in psutil.process_iter():
if proc.name == PROCNAME:
print proc
What I get is nothing even though the process is running.
I was experiencing the same problem. Changing proc.name
to proc.name()
solved it for me if anyone else was having similar issues.
There have been significant changes in the psutil
API with version 2.0.0:
https://github.com/giampaolo/psutil/blob/master/HISTORY.rst#200---2014-03-10
The proc.name
class property was replaced by the proc.name()
method. So you need to adapt this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With