*************************************************************************** IPython post-mortem report {'commit_hash': '9ca5c4454', 'commit_source': 'installation', 'default_encoding': 'utf-8', 'ipython_path': '/usr/lib/python3.9/site-packages/IPython', 'ipython_version': '7.23.1', 'os_name': 'posix', 'platform': 'Linux-5.12.2-arch1-1-x86_64-with-glibc2.33', 'sys_executable': '/usr/bin/python', 'sys_platform': 'linux', 'sys_version': '3.9.5 (default, May 9 2021, 14:00:28) \n[GCC 10.2.0]'} *************************************************************************** *************************************************************************** Crash traceback: --------------------------------------------------------------------------- --------------------------------------------------------------------------- ModuleNotFoundError Python 3.9.5: /usr/bin/python Tue May 11 15:56:21 2021 A problem occurred executing Python code. Here is the sequence of function calls leading up to the error, with the most recent (innermost) call last. /usr/bin/sage-ipython in 1 #!/usr/bin/python 2 # -*- coding: utf-8 -*- 3 """ 4 Sage IPython startup script. 5 """ 6 7 # Display startup banner. Do this before anything else to give the user 8 # early feedback that Sage is starting. 9 from sage.misc.banner import banner 10 banner() 11 12 from sage.repl.interpreter import SageTerminalApp 13 14 app = SageTerminalApp.instance() ---> 15 app.initialize() global app.initialize = > 16 app.start() /usr/lib/python3.9/site-packages/traitlets/config/application.py in inner(app=, *args=(), **kwargs={}) 72 else: 73 raise ValueError("Unsupported value for environment variable: 'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."% _envvar ) 74 75 76 def catch_config_error(method): 77 """Method decorator for catching invalid config (Trait/ArgumentErrors) during init. 78 79 On a TraitError (generally caused by bad config), this will print the trait's 80 message, and exit the app. 81 82 For use on init methods, to prevent invoking excepthook on invalid input. 83 """ 84 @functools.wraps(method) 85 def inner(app, *args, **kwargs): 86 try: ---> 87 return method(app, *args, **kwargs) global method = undefined app = args = () kwargs = {} 88 except (TraitError, ArgumentError) as e: 89 app.log.fatal("Bad config encountered during initialization: %s", e) 90 app.log.debug("Config at the time: %s", app.config) 91 app.exit(1) 92 93 return inner 94 95 class ApplicationError(Exception): 96 pass 97 98 99 class LevelFormatter(logging.Formatter): 100 """Formatter with additional `highlevel` record 101 102 This field is empty if log level is less than highlevel_limit, /usr/lib/python3.9/site-packages/IPython/terminal/ipapp.py in initialize(self=, argv=None) 302 303 return super(TerminalIPythonApp, self).parse_command_line(argv) 304 305 @catch_config_error 306 def initialize(self, argv=None): 307 """Do actions after construct, but before starting the app.""" 308 super(TerminalIPythonApp, self).initialize(argv) 309 if self.subapp is not None: 310 # don't bother initializing further, starting subapp 311 return 312 # print self.extra_args 313 if self.extra_args and not self.something_to_run: 314 self.file_to_run = self.extra_args[0] 315 self.init_path() 316 # create the shell --> 317 self.init_shell() self.init_shell = > 318 # and draw the banner 319 self.init_banner() 320 # Now a variety of things that happen after the banner is printed. 321 self.init_gui_pylab() 322 self.init_extensions() 323 self.init_code() 324 325 def init_shell(self): 326 """initialize the InteractiveShell instance""" 327 # Create an InteractiveShell instance. 328 # shell.display_banner should always be False for the terminal 329 # based app, because we call shell.show_banner() by hand below 330 # so the banner shows *before* all extension loading stuff. 331 self.shell = self.interactive_shell_class.instance(parent=self, 332 profile_dir=self.profile_dir, /usr/lib/python3.9/site-packages/sage/repl/interpreter.py in init_shell(self=) 766 Initialize the :class:`SageInteractiveShell` instance. 767 768 .. note:: 769 770 This code is based on 771 :meth:`TerminalIPythonApp.init_shell`. 772 773 EXAMPLES:: 774 775 sage: from sage.repl.interpreter import SageTerminalApp 776 sage: app = SageTerminalApp.instance() 777 sage: app.shell 778 779 """ 780 # Shell initialization --> 781 self.shell = self.shell_class.instance( self.shell = None self.shell_class.instance = > global parent = undefined self = global config = undefined self.config = {'TerminalIPythonApp': {'display_banner': False, 'verbose_crash': True, 'test_shell': False, 'shell_class': }, 'InteractiveShell': {'prompts_class': , 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'TerminalInteractiveShell': {'prompts_class': , 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'InteractiveShellApp': {'extensions': ['sage']}, 'IPCompleter': {'use_jedi': False}, 'SageTerminalApp': {'force_interact': True}} global profile_dir = undefined self.profile_dir = global ipython_dir = undefined self.ipython_dir = '/home/$USER/.sage/ipython-5.0.0' 782 parent=self, 783 config=self.config, 784 profile_dir=self.profile_dir, 785 ipython_dir=self.ipython_dir) 786 self.shell.configurables.append(self) 787 self.shell.has_sage_extensions = SAGE_EXTENSION in self.extensions 788 789 # Load the %lprun extension if available 790 try: 791 import line_profiler 792 assert line_profiler # silence pyflakes 793 except ImportError: 794 pass 795 else: 796 self.extensions.append('line_profiler') /usr/lib/python3.9/site-packages/traitlets/config/configurable.py in instance(cls=, *args=(), **kwargs={'config': {'TerminalIPythonApp': {'display_banner': False,...se}, 'SageTerminalApp': {'force_interact': True}}, 'ipython_dir': '/home/$USER/.sage/ipython-5.0.0', 'parent': , 'profile_dir': }) 522 >>> class Foo(SingletonConfigurable): pass 523 >>> foo = Foo.instance() 524 >>> foo == Foo.instance() 525 True 526 527 Create a subclass that is retrived using the base class instance:: 528 529 >>> class Bar(SingletonConfigurable): pass 530 >>> class Bam(Bar): pass 531 >>> bam = Bam.instance() 532 >>> bam == Bar.instance() 533 True 534 """ 535 # Create and save the instance 536 if cls._instance is None: --> 537 inst = cls(*args, **kwargs) inst = undefined cls = args = () kwargs = {'parent': , 'config': {'TerminalIPythonApp': {'display_banner': False, 'verbose_crash': True, 'test_shell': False, 'shell_class': }, 'InteractiveShell': {'prompts_class': , 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'TerminalInteractiveShell': {'prompts_class': , 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'InteractiveShellApp': {'extensions': ['sage']}, 'IPCompleter': {'use_jedi': False}, 'SageTerminalApp': {'force_interact': True}}, 'profile_dir': , 'ipython_dir': '/home/$USER/.sage/ipython-5.0.0'} 538 # Now make sure that the instance will also be returned by 539 # parent classes' _instance attribute. 540 for subclass in cls._walk_mro(): 541 subclass._instance = inst 542 543 if isinstance(cls._instance, cls): 544 return cls._instance 545 else: 546 raise MultipleInstanceError( 547 "An incompatible sibling of '%s' is already instanciated" 548 " as singleton: %s" % (cls.__name__, type(cls._instance).__name__) 549 ) 550 551 @classmethod 552 def initialized(cls): /usr/lib/python3.9/site-packages/IPython/terminal/interactiveshell.py in __init__(self=, *args=(), **kwargs={'config': {'TerminalIPythonApp': {'display_banner': False,...se}, 'SageTerminalApp': {'force_interact': True}}, 'ipython_dir': '/home/$USER/.sage/ipython-5.0.0', 'parent': , 'profile_dir': }) 510 511 def init_alias(self): 512 # The parent class defines aliases that can be safely used with any 513 # frontend. 514 super(TerminalInteractiveShell, self).init_alias() 515 516 # Now define aliases that only make sense on the terminal, because they 517 # need direct access to the console in a way that we can't emulate in 518 # GUI or web frontend 519 if os.name == 'posix': 520 for cmd in ('clear', 'more', 'less', 'man'): 521 self.alias_manager.soft_define_alias(cmd, cmd) 522 523 524 def __init__(self, *args, **kwargs): --> 525 super(TerminalInteractiveShell, self).__init__(*args, **kwargs) global super = undefined global TerminalInteractiveShell = self.__init__ = > args = () kwargs = {'parent': , 'config': {'TerminalIPythonApp': {'display_banner': False, 'verbose_crash': True, 'test_shell': False, 'shell_class': }, 'InteractiveShell': {'prompts_class': , 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'TerminalInteractiveShell': {'prompts_class': , 'ast_node_interactivity': 'all', 'colors': 'LightBG', 'simple_prompt': False, 'term_title': True, 'confirm_exit': False, 'separate_in': ''}, 'InteractiveShellApp': {'extensions': ['sage']}, 'IPCompleter': {'use_jedi': False}, 'SageTerminalApp': {'force_interact': True}}, 'profile_dir': , 'ipython_dir': '/home/$USER/.sage/ipython-5.0.0'} 526 self.init_prompt_toolkit_cli() 527 self.init_term_title() 528 self.keep_running = True 529 530 self.debugger_history = InMemoryHistory() 531 532 def ask_exit(self): 533 self.keep_running = False 534 535 rl_next_input = None 536 537 def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED): 538 539 if display_banner is not DISPLAY_BANNER_DEPRECATED: 540 warn('interact `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2) /usr/lib/python3.9/site-packages/IPython/core/interactiveshell.py in __init__(self=, ipython_dir='/home/$USER/.sage/ipython-5.0.0', profile_dir=, user_module=None, user_ns=None, custom_exceptions=((), None), **kwargs={'config': {'TerminalIPythonApp': {'display_banner': False,...se}, 'SageTerminalApp': {'force_interact': True}}, 'parent': }) 669 self.init_pushd_popd_magic() 670 self.init_user_ns() 671 self.init_logger() 672 self.init_builtins() 673 674 # The following was in post_config_initialization 675 self.init_inspector() 676 self.raw_input_original = input 677 self.init_completer() 678 # TODO: init_io() needs to happen before init_traceback handlers 679 # because the traceback handlers hardcode the stdout/stderr streams. 680 # This logic in in debugger.Pdb and should eventually be changed. 681 self.init_io() 682 self.init_traceback_handlers(custom_exceptions) 683 self.init_prompts() --> 684 self.init_display_formatter() self.init_display_formatter = > 685 self.init_display_pub() 686 self.init_data_pub() 687 self.init_displayhook() 688 self.init_magics() 689 self.init_alias() 690 self.init_logstart() 691 self.init_pdb() 692 self.init_extension_manager() 693 self.init_payload() 694 self.init_deprecation_warnings() 695 self.hooks.late_startup_hook() 696 self.events.trigger('shell_initialized', self) 697 atexit.register(self.atexit_operations) 698 699 # The trio runner is used for running Trio in the foreground thread. It /usr/lib/python3.9/site-packages/sage/repl/interpreter.py in init_display_formatter(self=) 289 sage: SageTerminalInteractiveShell() # not tested 290 291 """ 292 293 def init_display_formatter(self): 294 """ 295 Switch to the Sage IPython commandline rich output backend 296 297 EXAMPLES:: 298 299 sage: from sage.repl.interpreter import SageTerminalInteractiveShell 300 sage: SageTerminalInteractiveShell().init_display_formatter() # not tested 301 """ 302 from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline 303 backend = BackendIPythonCommandline() --> 304 backend.get_display_manager().switch_backend(backend, shell=self) backend.get_display_manager.switch_backend = undefined backend = IPython command line global shell = undefined self = 305 306 307 class SageTestShell(SageShellOverride, TerminalInteractiveShell): 308 """ 309 Test Shell 310 311 Care must be taken in these doctests to quit the test shell in 312 order to switch back the rich output display backend to the 313 doctest backend. 314 315 EXAMPLES:: 316 317 sage: from sage.repl.interpreter import get_test_shell 318 sage: shell = get_test_shell(); shell 319 /usr/lib/python3.9/site-packages/sage/repl/rich_output/display_manager.py in switch_backend(self=The Sage display manager using the IPython command line backend, backend=IPython command line, **kwds={'shell': }) 310 raise ValueError('every backend must support plain text') 311 try: 312 self._backend.uninstall() 313 except AttributeError: 314 pass # first time we switch 315 # clear caches 316 self._output_promotions = dict() 317 self._supported_output = frozenset( 318 map(self._demote_output_class, backend.supported_output())) 319 # install new backend 320 try: 321 old_backend = self._backend 322 except AttributeError: 323 old_backend = None 324 self._backend = backend --> 325 self._backend.install(**kwds) self._backend.install = kwds = {'shell': } 326 self._preferences = DisplayPreferences(self._backend.default_preferences()) 327 return old_backend 328 329 @property 330 def preferences(self): 331 """ 332 Return the preferences. 333 334 OUTPUT: 335 336 The display preferences as instance of 337 :class:`~sage.repl.rich_output.preferences.DisplayPreferences`. 338 339 EXAMPLES:: 340 /usr/lib/python3.9/site-packages/sage/repl/rich_output/backend_ipython.py in install(self=IPython command line, **kwds={'shell': }) 45 46 No tests since switching away from the doctest rich output 47 backend will break the doctests. 48 49 EXAMPLES:: 50 51 sage: from sage.repl.interpreter import get_test_shell 52 sage: from sage.repl.rich_output.backend_ipython import BackendIPython 53 sage: backend = BackendIPython() 54 sage: shell = get_test_shell() 55 sage: backend.install(shell=shell) 56 sage: shell.run_cell('1+1') 57 2 58 """ 59 shell = kwds['shell'] ---> 60 from sage.repl.display.formatter import SageDisplayFormatter global sage.repl.display.formatter = undefined SageDisplayFormatter = undefined 61 shell.display_formatter = SageDisplayFormatter(parent=shell) 62 shell.configurables.append(shell.display_formatter) 63 64 def set_underscore_variable(self, obj): 65 """ 66 Set the ``_`` builtin variable. 67 68 Since IPython handles the history itself, this does nothing. 69 70 INPUT: 71 72 - ``obj`` -- anything. 73 74 EXAMPLES:: 75 /usr/lib/python3.9/site-packages/sage/repl/display/formatter.py in 54 # **************************************************************************** 55 # Copyright (C) 2014 Volker Braun 56 # 57 # Distributed under the terms of the GNU General Public License (GPL) 58 # as published by the Free Software Foundation; either version 2 of 59 # the License, or (at your option) any later version. 60 # https://www.gnu.org/licenses/ 61 # **************************************************************************** 62 63 from io import StringIO 64 65 from IPython.core.formatters import DisplayFormatter, PlainTextFormatter 66 from IPython.utils.py3compat import unicode_to_str 67 from IPython.core.display import DisplayObject 68 ---> 69 from ipywidgets.widgets.interaction import interactive global ipywidgets.widgets.interaction = undefined global interactive = undefined 70 71 from sage.repl.display.pretty_print import SagePrettyPrinter 72 73 IPYTHON_NATIVE_TYPES = (DisplayObject, interactive) 74 75 PLAIN_TEXT = 'text/plain' 76 TEXT_LATEX = 'text/latex' 77 TEXT_HTML = 'text/html' 78 79 80 class SageDisplayFormatter(DisplayFormatter): 81 82 def __init__(self, *args, **kwds): 83 """ 84 This is where the Sage rich objects are translated to IPython ModuleNotFoundError: No module named 'ipywidgets' *************************************************************************** History of session input: