psutil error on macos

南楼画角 提交于 2020-01-07 03:15:08

问题


def showMemTime(when='Resources'):
  global maxmem
  # memory and time measurement
  process = psutil.Process(os.getpid())
  mem = process.get_memory_info()[0] / float(2 ** 20)
  maxmem = max(maxmem, mem)
  ts = process.get_cpu_times()
  sys.stderr.write("{when:<20}: {mb:4.0f} MB (max {maxmb:4.0f} MB), {user:4.1f} s user, {system:4.1f} s system\n".format(
    when=when, mb=mem, maxmb=maxmem, user=ts.user, system=ts.system))

I'm trying to use the code above. But i get "AttributeError: 'Process' object has no attribute 'get_memory_info'" I'm on Python 2.7, psutil 5.0.0 and macOS Sierra

Thank you.


回答1:


Process class doesn't have a method named get_memory_info. It has memory_full_info() and memory_info() psutil.Process



来源:https://stackoverflow.com/questions/41012058/psutil-error-on-macos

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