[英]psutil error on macos
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' object has no attribute 'get_memory_info'” 我使用的是 Python 2.7、psutil 5.0.0 和 macOS Sierra
謝謝你。
Process 類沒有名為get_memory_info
的方法。 它有memory_full_info()
和memory_info()
psutil.Process
已從 macos 中刪除了有關metmirr 的附加信息,這可能就是人們仍然遇到此問題的原因。
在 5.6.0 版更改:刪除了 macOS 支持,因為它本身就已損壞(請參閱問題 #1291)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.