7a2b19
diff --git a/base/module.py b/base/module.py
7a2b19
index dd3efa3..04ac5b8 100644
7a2b19
--- a/base/module.py
7a2b19
+++ b/base/module.py
7a2b19
@@ -432,6 +432,12 @@ class Module(object):
7a2b19
         if show_usage is not None:
7a2b19
             sys.exit(0)
7a2b19
 
7a2b19
+        if mode == GUI_MODE:
7a2b19
+            if not utils.canEnterGUIMode4():
7a2b19
+                log.warn("GUI mode not available - switching to interactive mode.")
7a2b19
+                mode = INTERACTIVE_MODE
7a2b19
+                ui_toolkit = 'none'
7a2b19
+
7a2b19
         self.mode = mode
7a2b19
         return opts, device_uri, printer_name, mode, ui_toolkit, lang
7a2b19
 
7a2b19
diff --git a/base/utils.py b/base/utils.py
7a2b19
index 98437a3..9b8813b 100644
7a2b19
--- a/base/utils.py
7a2b19
+++ b/base/utils.py
7a2b19
@@ -722,6 +722,15 @@ def canEnterGUIMode4(): # qt4
7a2b19
             log.warn(e)
7a2b19
             return False
7a2b19
 
7a2b19
+        try:
7a2b19
+            import ui4
7a2b19
+        except ImportError:
7a2b19
+            try:
7a2b19
+                import ui5
7a2b19
+            except ImportError as e:
7a2b19
+                log.warn(e)
7a2b19
+                return False
7a2b19
+
7a2b19
     return True
7a2b19
 
7a2b19
 
7a2b19
@@ -734,6 +743,11 @@ def checkPyQtImport(): # qt3
7a2b19
         if os.getenv('DISPLAY') and os.getenv('STARTED_FROM_MENU'):
7a2b19
             no_qt_message_gtk()
7a2b19
 
7a2b19
+        try:
7a2b19
+            import ui
7a2b19
+        except ImportError:
7a2b19
+            return False
7a2b19
+
7a2b19
         log.error("PyQt not installed. GUI not available. Exiting.")
7a2b19
         return False
7a2b19
 
7a2b19
@@ -781,11 +795,13 @@ def checkPyQtImport4():
7a2b19
         import PyQt4
7a2b19
         import ui4
7a2b19
     except ImportError:
7a2b19
-        import PyQt5
7a2b19
-        import ui5
7a2b19
-    else:
7a2b19
-        log.debug("HPLIP is not installed properly or is installed without graphical support. Please reinstall HPLIP again")
7a2b19
-        return False
7a2b19
+        try:
7a2b19
+            import PyQt5
7a2b19
+            import ui5
7a2b19
+        except ImportError:
7a2b19
+            log.debug('GUI not available.')
7a2b19
+            return False
7a2b19
+
7a2b19
     return True
7a2b19
 
7a2b19
 # def checkPyQtImport5():
7a2b19
diff --git a/fab.py b/fab.py
7a2b19
index 5577af5..194ceed 100755
7a2b19
--- a/fab.py
7a2b19
+++ b/fab.py
7a2b19
@@ -776,14 +776,15 @@ mod.setUsage(module.USAGE_FLAG_NONE)
7a2b19
 opts, device_uri, printer_name, mode, ui_toolkit, loc = \
7a2b19
     mod.parseStdOpts(handle_device_printer=False)
7a2b19
 
7a2b19
-if ui_toolkit == 'qt3':
7a2b19
-    if not utils.canEnterGUIMode():
7a2b19
-        log.error("%s GUI mode requires GUI support (try running with --qt4). Entering interactive mode." % __mod__)
7a2b19
-        mode = INTERACTIVE_MODE
7a2b19
-else:
7a2b19
-    if not utils.canEnterGUIMode4():
7a2b19
-        log.error("%s GUI mode requires GUI support (try running with --qt3). Entering interactive mode." % __mod__)
7a2b19
-        mode = INTERACTIVE_MODE
7a2b19
+if ui_toolkit != 'none':
7a2b19
+    if ui_toolkit == 'qt3':
7a2b19
+        if not utils.canEnterGUIMode():
7a2b19
+            log.error("%s GUI mode requires GUI support (try running with --qt4). Entering interactive mode." % __mod__)
7a2b19
+            mode = INTERACTIVE_MODE
7a2b19
+    else:
7a2b19
+        if not utils.canEnterGUIMode4():
7a2b19
+            log.error("%s GUI mode requires GUI support (try running with --qt3). Entering interactive mode." % __mod__)
7a2b19
+            mode = INTERACTIVE_MODE
7a2b19
 
7a2b19
 
7a2b19
 if mode == GUI_MODE: