nicolargo/glances · warning
Plugin {plugin} already in sys.modules, skipping (workaround
Error message
Plugin {plugin} already in sys.modules, skipping (workaround: rename plugin) What it means
A logged warning (not a raised error) emitted while loading additional plugins from a configured directory: the plugin's module name already exists in sys.modules, so Glances skips importing it to avoid double-import side effects. The message suggests renaming the plugin as a workaround.
Source
Thrown at glances/stats.py:223
path = args.plugin_dir
# No additional plugin directory configured.
if not path:
return
# Store original sys.path so it can be restored after loading.
_sys_path = sys.path
# Used to measure plugin startup duration.
start_duration = Counter()
# Ensure plugins can be imported from the configured directory.
sys.path.insert(0, path)
for plugin in self._get_addl_plugins(path):
# Prevent duplicate imports for plugins already loaded.
if plugin in sys.modules:
logger.warn(f"Plugin {plugin} already in sys.modules, skipping (workaround: rename plugin)")
continue
start_duration.reset()
try:
# Dynamically import the plugin model module.
_mod_loaded = import_module(plugin + '.model')
# Create and register the plugin instance.
self._plugins[plugin] = _mod_loaded.PluginModel(args=args, config=config)
logger.debug(f"Plugin {plugin} started in {start_duration.get()} seconds")
except Exception as e:
# If a plugin can not be loaded, display a critical message
# on the console but do not crash
logger.critical(f"Error while initializing the {plugin} plugin ({e})")
logger.error(traceback.format_exc())
# An error occurred, disable the plugin
if args:
setattr(args, 'disable_' + plugin, False)View on GitHub (pinned to a240d8dfb3)
Solutions
- Rename the custom plugin's module (directory/package name) to something unique, as the message suggests
- Remove the duplicate copy if the built-in already covers it
- Verify only one plugin path supplies each name; check sys.modules keys if unsure
- Restart glances after renaming so the old module isn't already cached
Example fix
# before # dir: glances_foo/ (collides with built-in 'glances_foo') # after mv glances_foo glances_foo_custom
Defensive patterns
Strategy: validation
Validate before calling
import sys, pathlib
names = {p.name for p in pathlib.glob(plugin_dir)}
clashes = names & set(sys.modules)
if clashes:
raise SystemExit(f'rename plugins to avoid collisions: {clashes}') Type guard
def plugin_name_free(name: str) -> bool:
import sys
return name not in sys.modules Prevention
- Give custom plugins unique module names distinct from built-ins
- Don't copy stock plugins into --plugins-dir without renaming
- Restart glances after renaming plugins so sys.modules is clean
When it happens
Trigger: Configuring additional plugin directories (--plugins-dir / plugin_path) that contain a plugin whose module name collides with a built-in or already-loaded one — e.g. a custom 'glances_plugin/foo' named the same as an existing plugin.
Common situations: Copying a stock plugin into a custom dir to modify it but keeping the module name; multiple plugin dirs containing same-named modules; iterating on plugins in the same interpreter/session.
Related errors
- Cannot get help view data ({str(e)})
- Cannot get plugin {plugin} ({str(e)})
- '{self.__class__.__name__}' object has no key '{item}'
- {item}
- Cannot get plugin list ({str(e)})
AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27).
Data as JSON: /api/errors/5d603758e8e4a5e6.
Report an issue: GitHub.