glances icon indicating copy to clipboard operation
glances copied to clipboard

No module named 'influxdb' on the snap version of glances

Open gbonazzoli opened this issue 4 years ago • 9 comments

Description

I'm using the snap version of glances on Oracle Linux 8.2, in order to keep the operating system as clean as possible from package installation.

glances goes like a charm but I can not load an influxdb database withe the metrics collected.

[root@dblinux 902]# glances -C/root/glances.conf --export influxdb
Traceback (most recent call last):
  File "/snap/glances/902/bin/glances", line 33, in <module>
    sys.exit(load_entry_point('Glances==3.1.5', 'console_scripts', 'glances')())
  File "/snap/glances/902/lib/python3.5/site-packages/glances/__init__.py", line 143, in main
    start(config=config, args=args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/__init__.py", line 108, in start
    mode = GlancesMode(config=config, args=args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/standalone.py", line 51, in __init__
    self.stats = GlancesStats(config=config, args=args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/stats.py", line 48, in __init__
    self.load_modules(self.args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/stats.py", line 103, in load_modules
    self.load_exports(args=args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/stats.py", line 178, in load_exports
    export_module = __import__(self._exports_all[export_name])
  File "/snap/glances/902/lib/python3.5/site-packages/glances/exports/glances_influxdb.py", line 27, in <module>
    from influxdb import InfluxDBClient
ImportError: No module named 'influxdb'

I think it is only a problem on how the snap package is fullfilled.

Any chance to have an official snap with the functionality on board ?

Versions

[root@dblinux 902]# snap list
Name      Version        Rev    Tracking       Publisher    Notes
glances   3.1.5          902    latest/stable  nicolargo    -

[root@dblinux 902]# glances -V
Glances v3.1.5 with PsUtil v5.7.2
Log file: /root/snap/glances/902/.cache/glances/glances.log

gbonazzoli avatar Sep 26 '20 06:09 gbonazzoli

@Lin-Buo-Ren What do you think of this request ? Is there a simple and good way to include Glances extra module in the default Snap ? Or is it better to create a new "Glances-Full" Snap ?

nicolargo avatar Sep 26 '20 08:09 nicolargo

I'd say we bundle all deps in one package. Will check it out.

brlin-tw avatar Sep 26 '20 08:09 brlin-tw

@Lin-Buo-Ren In my opinion "bundle all deps in one snap package" is the right way.

No confusion at all for end users, also for those that want only to give "glances" a try before doing a full installation sorting out the extra-weight of the snap.

gbonazzoli avatar Sep 26 '20 09:09 gbonazzoli

Ok...

@Lin-Buo-Ren any availability to contribute to this issue ?

nicolargo avatar Sep 26 '20 09:09 nicolargo

Hello everybody

I have the same problem. It was working fine until the "latest version" of the docker-image was pulled on January, 24 2021. Following all the details:

docker-compose

glancesEXPORT:
        image: nicolargo/glances:latest
        container_name: glancesEXPORT
        restart: unless-stopped
        privileged: true
        networks:
            - t2_proxy
            - socket_proxy
        depends_on:
            - socket-proxy
        security_opt:
            - no-new-privileges:true
        pid: host
        volumes:
            - $USERDIR/glances/conf:/glances/conf/ # Use this if you want to add a glances.conf file
        environment:
          GLANCES_OPT: "-C /glances/conf/glances.conf --quiet --export influxdb"
          DOCKER_HOST: tcp://socket-proxy:2375

Since 24th same error message as above:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/glances/__main__.py", line 29, in <module>
    glances.main()
  File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 145, in main
    start(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 110, in start
    mode = GlancesMode(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/standalone.py", line 51, in __init__
    self.stats = GlancesStats(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 48, in __init__
    self.load_modules(self.args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 103, in load_modules
    self.load_exports(args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 178, in load_exports
    export_module = __import__(self._exports_all[export_name])
  File "/usr/local/lib/python3.9/site-packages/glances/exports/glances_influxdb.py", line 27, in <module>
    from influxdb import InfluxDBClient
ModuleNotFoundError: No module named 'influxdb'

Versions differ though:

root@835ce63e4375:/glances# glances -V
Glances v3.1.6.1 with PsUtil v5.8.0

akrea avatar Jan 29 '21 20:01 akrea

its me again.

I also tried to change the glances.conf to:

[influxdb]
host=localhost
port=8086
protocol=http
org=nicolargo
bucket=glances
token=EjFUTWe8U-MIseEAkaVIgVnej_TrnbdvEcRkaB1imstW7gapSqy6_6-8XD-yd51V0zUUpDy-kAdVD1purDLuxA==
# Prefix will be added for all measurement name
# Ex: prefix=foo
#     => foo.cpu
#     => foo.mem
# You can also use dynamic values
#prefix=`hostname`
prefix=localhost
# Tags will be added for all measurements
#tags=foo:bar,spam:eggs
# You can also use dynamic values
#tags=system:`uname -s`

as given in the documenation. I do have

X-Influxdb-Build: OSS
X-Influxdb-Version: 1.8.3

but then I get:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/glances/__main__.py", line 29, in <module>
    glances.main()
  File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 145, in main
    start(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 110, in start
    mode = GlancesMode(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/standalone.py", line 51, in __init__
    self.stats = GlancesStats(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 48, in __init__
    self.load_modules(self.args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 103, in load_modules
    self.load_exports(args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 178, in load_exports
    export_module = __import__(self._exports_all[export_name])
  File "/usr/local/lib/python3.9/site-packages/glances/exports/glances_influxdb2.py", line 27, in <module>
    from influxdb_client import InfluxDBClient, WriteOptions
ModuleNotFoundError: No module named 'influxdb_client?'

akrea avatar Jan 29 '21 20:01 akrea

@gbonazzoli Can you give a chance to the latest Glances version 3.4.0.1 available in SNAP,

nicolargo avatar May 17 '23 14:05 nicolargo

@nicolargo

Installation OK on Ubuntu 22.04:

root@empire:~# snap list
Name     Version       Rev    Tracking         Publisher   Notes
glances  3.4.0.1       1497   latest/stable    nicolargo   -
snapd    2.59.2        19122  latest/stable    canonical✓  snapd

Still have some problems with influxdb:

root@empire:~# glances --export influxdb
Traceback (most recent call last):
  File "/snap/glances/1497/bin/glances", line 8, in <module>
    sys.exit(main())
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/__init__.py", line 180, in main
    start(config=core.get_config(), args=core.get_args())
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/__init__.py", line 108, in start
    mode = GlancesMode(config=config, args=args)
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/standalone.py", line 44, in __init__
    self.stats = GlancesStats(config=config, args=args)
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/stats.py", line 39, in __init__
    self.load_modules(self.args)
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/stats.py", line 90, in load_modules
    self.load_exports(args=args)
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/stats.py", line 162, in load_exports
    export_module = __import__(self._exports_all[export_name])
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/exports/glances_influxdb.py", line 18, in <module>
    from influxdb import InfluxDBClient
ModuleNotFoundError: No module named 'influxdb'

gbonazzoli avatar May 19 '23 04:05 gbonazzoli

Related issue: https://github.com/nicolargo/glances/issues/2413

nicolargo avatar May 19 '23 09:05 nicolargo

For the moment package only include requirements.txt, not optional-requirements.txt: https://github.com/nicolargo/glances/blob/develop/snap/snapcraft.yaml#L49

nicolargo avatar Apr 08 '24 11:04 nicolargo