繁体   English   中英

python psutil.cpu_times_percent()。guest_nice AttributeError:“ scputimes”对象没有属性“ guest_nice”

[英]python psutil.cpu_times_percent().guest_nice AttributeError: 'scputimes' object has no attribute 'guest_nice'

我在linux机器(centos 6.10)python 2.6上使用。 我正在尝试安装使用python的psutil模块的工具,因此我也安装了psutil模块:

yum install python-psutil.x86_64
...
yum info python-psutil.x86_64
Installed Packages
Name        : python-psutil
Arch        : x86_64
Version     : 0.6.1
Release     : 1.el6
Size        : 354 k
Repo        : installed
From repo   : epel
Summary     : A process and system utilities module for Python
URL         : http://psutil.googlecode.com/
License     : BSD
Description : psutil is a module providing an interface for retrieving information on all
        : running processes and system utilization (CPU, memory, disks, network, users) in
        : a portable way by using Python, implementing many functionalities offered by
        : command line tools such as: ps, top, df, kill, free, lsof, free, netstat,
        : ifconfig, nice, ionice, iostat, iotop, uptime, pidof, tty, who, taskset, pmap.

但是,在工具本身中,我遇到了下一个错误:

ERROR:  AttributeError: 'module' object has no attribute 'get_sysinfo'
ERROR:  AttributeError: 'scputimes' object has no attribute 'guest_nice'

当我尝试将psutil导入python`s shell时,出现下一个错误:

>>> import psutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/psutil/__init__.py", line 64, in     <module>
    import psutil._pslinux as _psplatform
  File "/usr/lib64/python2.6/site-packages/psutil/_pslinux.py", line 89, in     <module>
    TOTAL_PHYMEM = _psutil_linux.get_sysinfo()[0]
AttributeError: 'module' object has no attribute 'get_sysinfo'

因此,我从pypi网站下载了psutil版本5.4.7的源代码,并将其手动安装在服务器上。 现在,当我导入模块时,出现下一个错误:

>>> import psutil
Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
  File "psutil/__init__.py", line 101, in <module>
    from . import _pslinux as _psplatform
  File "psutil/_pslinux.py", line 26, in <module>
    from . import _psutil_linux as cext
ImportError: cannot import name _psutil_linux

=============

更新

所以用yum删除psutil并用pip安装后,我可以导入模块,但是出现下一个错误:

>>> from psutil import cpu_times_percent, cpu_percent, cpu_count
>>> from os import getloadavg
>>> from psutil import cpu_times_percent, cpu_percent, cpu_count
>>> ct = cpu_times_percent()
>>> ct.guest_nice
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'scputimes' object has no attribute 'guest_nice'

我要安装的工具出现错误...我应该检查什么?

您需要像下面那样升级psutil lib

点安装psutil

然后尝试

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM