添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
想旅行的书签  ·  Jest ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

I'm using on my linux machine(centos 6.10) python 2.6. I'm trying to install a tool that uses python`s psutil module so I also installed psutil module :

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.

However in the tool itself I'm getting the next errors :

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

When I'm trying to import the psutil in python`s shell I'm getting the next error :

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

So I download the source of psutil version 5.4.7 from pypi site and installed it manualy on the server. Now when I import the module I'm getting the next error :

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

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

Update

So after removing the psutil with yum and installing with pip I can import the module but I'm getting the next error :

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

The tool I want to install is getting that error... What should I check ?

I have the latest version - 5.4.7 : pip install psutil Requirement already satisfied (use --upgrade to upgrade): psutil in /usr/lib64/python2.6/site-packages/psutil-5.4.7-py2.6-linux-x86_64.egg – JeyJ Aug 23, 2018 at 12:30 Yes it should be. But that lib missed when you installed manually with yum. Can you try with pip. – Ganesan Karuppasamy Aug 23, 2018 at 12:40 Yes, I removed the repo with yum and installed with pip but no change. Now I can import the psutil module but I'm getting another error, please check the main post – JeyJ Aug 23, 2018 at 12:42

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.