diff --git a/django_extensions/management/commands/shell_plus.py b/django_extensions/management/commands/shell_plus.py index c65929cc4..4c8ef61f4 100644 --- a/django_extensions/management/commands/shell_plus.py +++ b/django_extensions/management/commands/shell_plus.py @@ -248,9 +248,13 @@ def run_ipython(): def get_ptpython(): try: - from prompt_toolkit.contrib.repl import embed + from ptpython.repl import embed except ImportError: - return traceback.format_exc() + tb = traceback.format_exc() + try: # prompt_toolkit < v0.27 + from prompt_toolkit.contrib.repl import embed + except ImportError: + return tb def run_ptpython(): imported_objects = import_objects(options, self.style) @@ -261,9 +265,13 @@ def run_ptpython(): def get_ptipython(): try: - from prompt_toolkit.contrib.ipython import embed + from ptpython.ipython import embed except ImportError: - return traceback.format_exc() + tb = traceback.format_exc() + try: # prompt_toolkit < v0.27 + from prompt_toolkit.contrib.ipython import embed + except ImportError: + return tb def run_ptipython(): imported_objects = import_objects(options, self.style)