Error while installing Glances: attributeError module object has no attribute...

HI all,

I installed glances (network monitor tool) from https://software.opensuse.org/package/glances but get an error when trying to run it. I get:

Traceback (most recent call last):
                                    File "/usr/bin/glances", line 9, in <module>
                                                                                    load_entry
                                                                                               "/usr/lib/python2.7/site-packages/glances/glances.py", line 2237, in  main
                                                                             stats.update()
                                                                                             F 751, in update
                   self.__update__()
                                      File "/usr/lib/python2.7/site-packages/glances/glances.p
                                                                                              s:
  AttributeError: 'module' object has no attribute 'error'

After searching all over I cannot find a fix. I am a new convert from Ubuntu, so that could be a factor :).

Thanks in advance for any help given.

I was able to replicate your error with packages from two of the repositories on home:napobear and home:randybb. i’m not enough of a python guru to tell what the problem is with python.

However I do have a workaround!

Uninstall glances

sudo zypper rm glances

Install python-pip

sudo zypper install python-pip

Install Glances with pip. Pip is a package manager built for Python

sudo pip install --force glances

It should be working now. You might need to zypper install gcc also if you don’t have it.

I tried this again on a new fresh install and I wanted to give the extra dependencies required if my former steps don’t work for someone.

sudo zypper install python-pip python3-pip python3-devel gcc

Rather create a bugreport on bugzilla.opensuse.org, so that the dependencies of the package can be fixed to meet the actual requirements

Ok, so I tried the above and it still did not work. Here is the output:

pip install --force glances     
Collecting glances
  Using cached Glances-2.7.1.tar.gz
Collecting psutil>=2.0.0 (from glances)
  Using cached psutil-5.0.0.zip
Installing collected packages: psutil, glances
  Running setup.py install for psutil ... error                                                                                                              
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1_6koows/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-rlhthwi0-record/install-record.txt --single-version-externally-managed --compile:                                                                                                   
    running install                                                                                                                                          
    running build                                                                                                                                            
    running build_py                                                                                                                                         
    creating build                                                                                                                                           
    creating build/lib.linux-x86_64-3.4                                                                                                                      
    creating build/lib.linux-x86_64-3.4/psutil                                                                                                               
    copying psutil/_common.py -> build/lib.linux-x86_64-3.4/psutil                                                                                           
    copying psutil/_psposix.py -> build/lib.linux-x86_64-3.4/psutil
    copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.4/psutil
    copying psutil/_pslinux.py -> build/lib.linux-x86_64-3.4/psutil
    copying psutil/_compat.py -> build/lib.linux-x86_64-3.4/psutil
    copying psutil/_psosx.py -> build/lib.linux-x86_64-3.4/psutil
    copying psutil/_pssunos.py -> build/lib.linux-x86_64-3.4/psutil
    copying psutil/__init__.py -> build/lib.linux-x86_64-3.4/psutil
    copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.4/psutil
    creating build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/runner.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-3.4/psutil/tests
    copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-3.4/psutil/tests
    running build_ext
    building 'psutil._psutil_linux' extension
    creating build/temp.linux-x86_64-3.4
    creating build/temp.linux-x86_64-3.4/psutil
    gcc -pthread -Wno-unused-result -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=500 -DPSUTIL_LINUX=1 -I/usr/include/python3.4m -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-3.4/psutil/_psutil_linux.o
    psutil/_psutil_linux.c:12:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1_6koows/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-rlhthwi0-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-1_6koows/psutil/
linux-tf2o:~ # 

However, it appears I already have gcc installed:

linux-tf2o:~ # zypper install gcc
Loading repository data...
Reading installed packages...
'gcc' is already installed.
No update candidate for 'gcc-4.8-9.61.x86_64'. The highest available version is already installed.
Resolving package dependencies...

Nothing to do.

So I did:


inux-tf2o:~ #         sudo zypper install python-pip python3-pip python3-devel gcc
Loading repository data...
Reading installed packages...
'gcc' is already installed.
No update candidate for 'gcc-4.8-9.61.x86_64'. The highest available version is already installed.
'python3-pip' is already installed.
No update candidate for 'python3-pip-7.1.2-5.3.noarch'. The highest available version is already installed.
'python-pip' is already installed.
No update candidate for 'python-pip-7.1.2-2.4.noarch'. The highest available version is already installed.
Resolving package dependencies...

The following NEW package is going to be installed:
  python3-devel

1 new package to install.
Overall download size: 135.1 KiB. Already cached: 0 B. After the operation, additional 495.8 KiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package python3-devel-3.4.5-9.1.x86_64                                                                       (1/1), 135.1 KiB (495.8 KiB unpacked)
Retrieving: python3-devel-3.4.5-9.1.x86_64.rpm ........................................................................................................[done]
Checking for file conflicts: ..........................................................................................................................[done]
(1/1) Installing: python3-devel-3.4.5-9.1.x86_64 ......................................................................................................[done]

and then tried to install again and was successful:

inux-tf2o:~ # pip install --force glances
Collecting glances
  Using cached Glances-2.7.1.tar.gz
Collecting psutil>=2.0.0 (from glances)
  Using cached psutil-5.0.0.zip
Installing collected packages: psutil, glances
  Running setup.py install for psutil ... done
  Running setup.py install for glances ... done
Successfully installed glances-2.7.1 psutil-5.0.0

However, after that I tried to run glances again but got another error:

linux-tf2o:~ # glances
Curses module not found. Glances cannot start in standalone mode.

So, I read about this error online, then tried to install curses, but only one was already installed and the other two are not found:

l

inux-tf2o:~ # apt-get install libncurses5 libncurses5-dev libncursesw5                                                                                      
Loading repository data...                                                                                                                                   
Reading installed packages...                                                                                                                                
Package 'libncurses5-devel' not found.                                                                                                                       
'libncurses5' is already installed.                                                                                                                          
No update candidate for 'libncurses5-5.9-54.48.x86_64'. The highest available version is already installed.                                                  
'libncursesw5' not found in package names. Trying capabilities.                                                                                              
No provider of 'libncursesw5' found.
Resolving package dependencies...

Nothing to do.

This is where I am now. Still not able to run glances.

Hi
There is a later version out 2.7, not sure what your doing wrong, probably not using pip3 and python3 tools… :wink:

I’ve built and packaged it up as an rpm and built with python3 and working fine on openSUSE 42.2;
https://build.opensuse.org/package/show/home:malcolmlewis:TESTING/glances

Download from here when it’s built and published and manually install;
http://download.opensuse.org/repositories/home:/malcolmlewis:/TESTING/openSUSE_Leap_42.2/noarch/

http://thumbnails116.imagebam.com/51614/0596ff516135259.jpg](http://www.imagebam.com/image/0596ff516135259)

l

inux-tf2o:~ # apt-get install libncurses5 libncurses5-dev libncursesw5                                                                                      
Loading repository data...                                                                                                                                   
Reading installed packages...                                                                                                                                
Package 'libncurses5-devel' not found.                                                                                                                       
'libncurses5' is already installed.                                                                                                                          
No update candidate for 'libncurses5-5.9-54.48.x86_64'. The highest available version is already installed.                                                  
'libncursesw5' not found in package names. Trying capabilities.                                                                                              
No provider of 'libncursesw5' found.
Resolving package dependencies...

Nothing to do.

This is where I am now. Still not able to run glances.

You’re missing python3-curses

zypper install python3-curses

I found this by doing:

$ zypper search curses
Loading repository data...
Reading installed packages...

S | Name                     | Summary                                 | Type
--+--------------------------+-----------------------------------------+--------
i | libncurses5              | The New curses Libraries                | package
  | libncurses5-32bit        | The New curses Libraries                | package
i | libncurses6              | The New curses Libraries                | package
  | libncurses6-32bit        | The New curses Libraries                | package
  | libyui-ncurses-devel     | Libyui-ncurses header files             | package
  | libyui-ncurses-doc       | Libyui-ncurses documentation            | package
  | libyui-ncurses-pkg-devel | Libyui-ncurses-pkg header files         | package
  | libyui-ncurses-pkg-doc   | Libyui-ncurses-pkg documentation        | package
i | libyui-ncurses-pkg7      | Libyui - yast2 package selector widge-> | package
i | libyui-ncurses7          | Libyui - Character Based User Interface | package
  | ncurses-devel            | Include Files and Libraries mandatory-> | package
  | ncurses-devel-32bit      | Include Files and Libraries mandatory-> | package
i | ncurses-utils            | Tools using the new curses libraries    | package
  | ocaml-curses             | OCaml bindings for ncurses              | package
  | ocaml-curses-devel       | Development files for ocaml-curses      | package
  | perl-Curses              | Terminal screen handling and optimiza-> | package
  | perl-CursesWidgets       | CursesWidgets Perl module               | package
  | python-curses            | Python Interface to the (N)Curses Lib-> | package
i | python3-curses           | Python Interface to the (N)Curses Lib-> | package

I hope it’s working for you now.

Yes! Thanks so much for your help. Hopefully this will help someone else with a similar problem.