diff --git a/scapy/main.py b/scapy/main.py index 111357853..b8bc56bff 100644 --- a/scapy/main.py +++ b/scapy/main.py @@ -502,10 +502,13 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20): "traitlets not available. Some Scapy shell features won't be " "available." ) - ipshell = InteractiveShellEmbed( - banner1=banner, - user_ns=SESSION, - ) + try: + ipshell = InteractiveShellEmbed( + banner1=banner, + user_ns=SESSION, + ) + except: + code.interact(banner = the_banner, local=SESSION) else: cfg = Config() try: @@ -518,10 +521,20 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20): cfg.TerminalInteractiveShell.separate_in = u'' cfg.TerminalInteractiveShell.hist_file = conf.histfile # configuration can thus be specified here. - ipshell = InteractiveShellEmbed(config=cfg, - banner1=banner, - hist_file=conf.histfile if conf.histfile else None, - user_ns=SESSION) + try: + ipshell = InteractiveShellEmbed(config=cfg, + banner1=banner, + hist_file=conf.histfile if conf.histfile else None, + user_ns=SESSION) + except (AttributeError, TypeError): + log_loading.warning("IPython too old. Won't support history and color style.") + try: + ipshell = InteractiveShellEmbed( + banner1=banner, + user_ns=SESSION, + ) + except: + code.interact(banner = the_banner, local=SESSION) ipshell(local_ns=SESSION) else: code.interact(banner = the_banner, local=SESSION) diff --git a/scapy/themes.py b/scapy/themes.py index 0ec5b720d..9a201a876 100644 --- a/scapy/themes.py +++ b/scapy/themes.py @@ -296,7 +296,7 @@ def apply_ipython_style(shell): except: from scapy.error import log_loading log_loading.warning( - "IPython too old. Some Scapy shell features won't be available." + "IPython too old. Shell color won't be handled." ) return from scapy.config import conf