【发布时间】:2015-05-16 21:04:56
【问题描述】:
我正在使用它来获取当前进程。它可以在我的机器上运行,但是当我在另一台机器上运行时它就不行了。
for p in psutil.process_iter():
try:
proc_names[p.pid] = p.name()
except psutil.Error:
pass
for c in psutil.net_connections(kind='inet'):
# etc...
我收到了这个错误
proc_names[p.pid] = p.name()
TypeError: 'str' object is not callable
通过使用 p.name,我得到了这个
for c in psutil.net_connections(kind='inet'):
AttributeError: 'module' object has no attribute 'net_connections'
【问题讨论】:
-
鲍勃,你测试一下这个link。你需要更新 psutil。