summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/main.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 000ded68..118a7480 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -303,8 +303,16 @@ def load_settings(fm, clean):
             ranger.fm = fm
             for plugin in sorted(plugins):
                 try:
-                    module = __import__('plugins', fromlist=[plugin])
-                    fm.commands.load_commands_from_module(module)
+                    try:
+                        # importlib does not exist before python2.7.  It's
+                        # required for loading commands from plugins, so you
+                        # can't use that feature in python2.6.
+                        import importlib
+                    except ImportError:
+                        module = __import__('plugins', fromlist=[plugin])
+                    else:
+                        module = importlib.import_module('plugins.' + plugin)
+                        fm.commands.load_commands_from_module(module)
                     fm.log.append("Loaded plugin '%s'." % plugin)
                 except Exception as e:
                     fm.log.append("Error in plugin '%s'" % plugin)