nicolargo/glances · error · Exception

Missing libs required to run LXD Extension (Containers)

Error message

Missing libs required to run LXD Extension (Containers)

What it means

Raised in the LXD engine's __init__ when disable_plugin_lxd indicates the LXD client libraries could not be imported. Like the other container engines, LXD support is optional and the engine refuses construction with a plain Exception when its imports failed at module load time.

Source

Thrown at glances/plugins/containers/engines/lxd.py:202

                old_net = self._old_computed_stats.get("network", {})
                if "cumulative_rx" in old_net:
                    stats["time_since_update"] = round(self.time_since_update)
                    stats["rx"] = max(0, cumulative_rx - old_net["cumulative_rx"])
                    stats["tx"] = max(0, cumulative_tx - old_net["cumulative_tx"])
        except (KeyError, TypeError) as e:
            logger.debug(f"containers (LXD) Instance({self._instance.name}): Can't grab NET stats ({e})")
        return stats


class LxdExtension:
    """Glances' Containers Plugin's LXD Extension unit"""

    CONTAINER_ACTIVE_STATUS = ['Running']

    def __init__(self, endpoint=None, poll_interval=2):
        self.disable = disable_plugin_lxd
        if self.disable:
            raise Exception("Missing libs required to run LXD Extension (Containers)")

        self.display_error = True
        self.client = None
        self.ext_name = "containers (LXD)"
        self.endpoint = endpoint
        self.poll_interval = poll_interval
        self.stats_fetchers = {}
        self.local_node = None

        self.connect()

    def connect(self) -> None:
        """Connect to the LXD server."""
        try:
            if self.endpoint:
                self.client = LxdClient(endpoint=self.endpoint)
            else:
                self.client = LxdClient()

View on GitHub (pinned to a240d8dfb3)

Solutions

  1. Install the LXD extra: pip install 'glances[lxd]' or the required lxd client package
  2. Run python -c 'import glances.plugins.containers.engines.lxd' to see the underlying ImportError
  3. On slim images, install the OpenSSL/libssl packages the LXD client links against
  4. Disable the LXD engine in config if it is not needed

Example fix

# before
$ pip install glances
# after
$ pip install 'glances[lxd]'
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
if importlib.util.find_spec('glances.plugins.containers.engines.lxd') is None:
    # check underlying client lib presence before use
    raise SystemExit('LXD engine unavailable')

Type guard

def lxd_engine_available() -> bool:
    try:
        import glances.plugins.containers.engines.lxd as m  # noqa
        return not m.disable_plugin_lxd
    except Exception:
        return False

Try / catch

try:
    engine = LxdGlancesContainerExtension(endpoint=...)
except Exception as e:
    if 'Missing libs' in str(e):
        engine = None
    else:
        raise

Prevention

When it happens

Trigger: Constructing LxdGlancesContainerExtension (directly or via the containers plugin) without the LXD client package installed/importable, or on platforms where the import raises (e.g. missing OpenSSL bindings used by the LXD client).

Common situations: Base glances install without LXD extras; minimal containers/alpine images lacking crypto libs the LXD SDK needs; stale virtualenvs after a package removal.

Related errors


AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27). Data as JSON: /api/errors/fd0787eb73112e6e. Report an issue: GitHub.