From e7133542732053b4fd9161d9097ce314a312d0a2 Mon Sep 17 00:00:00 2001 From: Parzival Wolfram Date: Thu, 15 Nov 2018 18:27:08 -0600 Subject: [PATCH] Apparently both can break on Py3 but apparently Pip can install shit mid-script in all editions of Python. Sweet. --- imports/terminal_handler.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/imports/terminal_handler.py b/imports/terminal_handler.py index 21928b0..b196516 100644 --- a/imports/terminal_handler.py +++ b/imports/terminal_handler.py @@ -4,7 +4,19 @@ import rlcompleter try: import readline except ImportError: - from imports import winreadline as readline + try: + from imports import winreadline as readline + except ImportError: + print("Required module not installed: readline\nAttempting to install with pip...") + try: + import pip + except ImportError: + sys.exit(1) + if hasattr(pip, 'main'): + pip.main(['install', 'readline']) + else: + pip._internal.main(['install', 'readline']) + import readline from imports import globals from imports import manysearches