【问题标题】:psutil error on macosmacos上的psutil错误
【发布时间】:2017-04-22 01:51:44
【问题描述】:
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

谢谢。

【问题讨论】:

    标签: python macos macos-sierra


    【解决方案1】:

    Process 类没有名为get_memory_info 的方法。它有memory_full_info() 和memory_info() psutil.Process

    【讨论】:

      【解决方案2】:

      metmirr 的附加信息 这已从 macos 中删除,这可能就是人们仍然遇到此问题的原因。

      在 5.6.0 版中更改:删除了 macOS 支持,因为它本身 损坏(参见问题 #1291)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-05
        • 2020-10-06
        • 1970-01-01
        • 2018-10-06
        • 2019-07-11
        • 1970-01-01
        • 2014-05-18
        • 1970-01-01
        相关资源
        最近更新 更多