本文介绍了MacOS上的psutil错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

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))

我正在尝试使用上面的代码.但是我收到"AttributeError:'Process'对象没有属性'get_memory_info'",我在Python 2.7,psutil 5.0.0和macOS Sierra上

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

谢谢.

推荐答案

Process类没有名为get_memory_info的方法.它具有memory_full_info()memory_info() psutil .处理

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

这篇关于MacOS上的psutil错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 20:51