Hi,
I encountered the following problems with sage:
1. It crashes when I am using tab auto completion - report attached.
2. Each time I want to use sage (by command 'sage') after restarting the
system I need to type 'conda activate sage'. Otherwise command sage is not
recognized ('-bash: sage: command not found').
I run Sage 9.2 on MacOS Big Sur 11.1 (Macbook Pro) which was installed by
Conda.
Best,
Maciek
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/CABdAJe%2BGEhGwML%2BO%2BVVqKsNkCPNBt5pmqPMssETzUnif__8q5Q%40mail.gmail.com.
***************************************************************************
IPython post-mortem report
{'commit_hash': '223e783c4',
'commit_source': 'installation',
'default_encoding': 'utf-8',
'ipython_path':
'/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython',
'ipython_version': '7.19.0',
'os_name': 'posix',
'platform': 'macOS-10.16-x86_64-i386-64bit',
'sys_executable': '/opt/miniconda3/envs/sage/bin/python',
'sys_platform': 'darwin',
'sys_version': '3.8.5 | packaged by conda-forge | (default, Sep 24 2020, '
'16:37:41) \n'
'[Clang 10.0.1 ]'}
***************************************************************************
***************************************************************************
Crash traceback:
---------------------------------------------------------------------------
---------------------------------------------------------------------------
TypeError Python 3.8.5: /opt/miniconda3/envs/sage/bin/python
Mon Jan 4 14:16:47 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.
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/terminal/ptutils.py
in get_completions(self=<IPython.terminal.ptutils.IPythonPTCompleter object>,
document=Document('cd Do', 5),
complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
112 try:
--> 113 yield from self._get_completions(body, offset,
cursor_position, self.ipy_completer)
self._get_completions = <function IPythonPTCompleter._get_completions
at 0x7f856bf95790>
body = 'cd Do'
offset = 5
cursor_position = 5
self.ipy_completer = <IPython.core.completer.IPCompleter object at
0x7f856c16ba00>
114 except Exception as e:
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/terminal/ptutils.py
in _get_completions(body='cd Do', offset=5, cursor_position=5,
ipyc=<IPython.core.completer.IPCompleter object>)
128 body, ipyc.completions(body, offset))
--> 129 for c in completions:
c = undefined
completions = <generator object _deduplicate_completions at
0x7f8571b6c6d0>
130 if not c.text:
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/core/completer.py
in _deduplicate_completions(text='cd Do', completions=<generator object
IPCompleter.completions>)
437 """
--> 438 completions = list(completions)
completions = <generator object IPCompleter.completions at
0x7f8571b6c660>
global list = undefined
439 if not completions:
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/core/completer.py
in completions(self=<IPython.core.completer.IPCompleter object>, text='cd Do',
offset=5)
1817 try:
-> 1818 for c in self._completions(text, offset,
_timeout=self.jedi_compute_type_timeout/1000):
c = undefined
self._completions = <bound method IPCompleter._completions of
<IPython.core.completer.IPCompleter object at 0x7f856c16ba00>>
text = 'cd Do'
offset = 5
global _timeout = undefined
self.jedi_compute_type_timeout = 400
1819 if c and (c in seen):
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/core/completer.py
in _completions(self=<IPython.core.completer.IPCompleter object>, full_text='cd
Do', offset=5, _timeout=0.4)
1860
-> 1861 matched_text, matches, matches_origin, jedi_matches =
self._complete(
matched_text = undefined
matches = undefined
matches_origin = undefined
jedi_matches = undefined
self._complete = <bound method IPCompleter._complete of
<IPython.core.completer.IPCompleter object at 0x7f856c16ba00>>
full_text = 'cd Do'
cursor_line = 0
global cursor_pos = undefined
cursor_column = 5
1862 full_text=full_text, cursor_line=cursor_line,
cursor_pos=cursor_column)
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/core/completer.py
in _complete(self=<IPython.core.completer.IPCompleter object>, cursor_line=0,
cursor_pos=5, line_buffer='cd Do', text='Do', full_text='cd Do')
2028 full_text = line_buffer
-> 2029 completions = self._jedi_matches(
completions = ()
self._jedi_matches = <bound method IPCompleter._jedi_matches of
<IPython.core.completer.IPCompleter object at 0x7f856c16ba00>>
cursor_pos = 5
cursor_line = 0
full_text = 'cd Do'
2030 cursor_pos, cursor_line, full_text)
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/core/completer.py
in _jedi_matches(self=<IPython.core.completer.IPCompleter object>,
cursor_column=5, cursor_line=0, text='cd Do')
1372
-> 1373 interpreter = jedi.Interpreter(
interpreter = undefined
global jedi.Interpreter = <class 'jedi.api.Interpreter'>
text = 'cd Do'
offset = 5
namespaces = undefined
global column = undefined
cursor_column = 5
global line = undefined
cursor_line = 0
1374 text[:offset], namespaces, column=cursor_column,
line=cursor_line + 1)
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/jedi/api/__init__.py in
__init__(self=<class 'jedi.api.Interpreter'> instance, code='cd Do',
namespaces=[{'AA': Algebraic Real Field, 'AbelianGroup': <function
AbelianGroup>, 'AbelianGroupMorphism': <class
'sage.groups.abelian_gps.abelian_group_morphism.AbelianGroupMorphism'>,
'AbelianGroupWithValues': <function AbelianGroupWithValues>, 'AbelianVariety':
<function AbelianVariety>, 'AdditiveAbelianGroup': <function
AdditiveAbelianGroup>, 'AdditiveAbelianGroupWrapper': <class
'sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapper'>,
'AdditiveAbelianGroupWrapperElement': <class
'sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapperElement'>,
'AdditiveMagmas': <class 'sage.categories.additive_magmas.AdditiveMagmas'>,
'AffineCryptosystem': <class 'sage.crypto.classical.AffineCryptosystem'>, ...},
{'AA': Algebraic Real Field, 'AbelianGroup': <function AbelianGroup>,
'AbelianGroupMorphism': <class
'sage.groups.abelian_gps.abelian_group_morphism.AbelianGroupMorphism'>,
'AbelianGroupWithValues': <function AbelianGroupWithValues>, 'AbelianVariety':
<function AbelianVariety>, 'AdditiveAbelianGroup': <function
AdditiveAbelianGroup>, 'AdditiveAbelianGroupWrapper': <class
'sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapper'>,
'AdditiveAbelianGroupWrapperElement': <class
'sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapperElement'>,
'AdditiveMagmas': <class 'sage.categories.additive_magmas.AdditiveMagmas'>,
'AffineCryptosystem': <class 'sage.crypto.classical.AffineCryptosystem'>,
...}], **kwds={'column': 5, 'line': 1})
724
--> 725 super().__init__(code, environment=environment,
global super.__init__ = undefined
code = 'cd Do'
environment = <jedi.api.environment.InterpreterEnvironment object at
0x7f8571b34940>
global project = <module 'jedi.api.project' from
'/opt/miniconda3/envs/sage/lib/python3.8/site-packages/jedi/api/project.py'>
global Project = <class 'jedi.api.project.Project'>
global Path.cwd = <bound method Path.cwd of <class 'pathlib.Path'>>
kwds = {'column': 5, 'line': 1}
726 project=Project(Path.cwd()), **kwds)
TypeError: __init__() got an unexpected keyword argument 'column'
During handling of the above exception, another exception occurred:
---------------------------------------------------------------------------
NameError Python 3.8.5: /opt/miniconda3/envs/sage/bin/python
Mon Jan 4 14:16:47 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.
/opt/miniconda3/envs/sage/bin/sage-ipython in <module>
1 #!/opt/miniconda3/envs/sage/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()
---> 16 app.start()
global app.start = <bound method TerminalIPythonApp.start of
<sage.repl.interpreter.SageTerminalApp object at 0x7f8568663df0>>
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/terminal/ipapp.py
in start(self=<sage.repl.interpreter.SageTerminalApp object>)
341 if self.log_level <= logging.INFO: print()
342
343 def _pylab_changed(self, name, old, new):
344 """Replace --pylab='inline' with --pylab='auto'"""
345 if new == 'inline':
346 warnings.warn("'inline' not available as pylab backend, "
347 "using 'auto' instead.")
348 self.pylab = 'auto'
349
350 def start(self):
351 if self.subapp is not None:
352 return self.subapp.start()
353 # perform any prexec steps:
354 if self.interact:
355 self.log.debug("Starting IPython's mainloop...")
--> 356 self.shell.mainloop()
self.shell.mainloop = <bound method TerminalInteractiveShell.mainloop
of <sage.repl.interpreter.SageTerminalInteractiveShell object at
0x7f856c172370>>
357 else:
358 self.log.debug("IPython not interactive...")
359 if not self.shell.last_execution_succeeded:
360 sys.exit(1)
361
362 def load_default_config(ipython_dir=None):
363 """Load the default config file from the default ipython_dir.
364
365 This is useful for embedded shells.
366 """
367 if ipython_dir is None:
368 ipython_dir = get_ipython_dir()
369
370 profile_dir = os.path.join(ipython_dir, 'profile_default')
371 app = TerminalIPythonApp()
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py
in mainloop(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>,
display_banner=<object object>)
549 if (not self.confirm_exit) \
550 or self.ask_yes_no('Do you really want to exit
([y]/n)?','y','n'):
551 self.ask_exit()
552
553 else:
554 if code:
555 self.run_cell(code, store_history=True)
556
557 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
558 # An extra layer of protection in case someone mashing Ctrl-C
breaks
559 # out of our internal code.
560 if display_banner is not DISPLAY_BANNER_DEPRECATED:
561 warn('mainloop `display_banner` argument is deprecated
since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning,
stacklevel=2)
562 while True:
563 try:
--> 564 self.interact()
self.interact = <bound method TerminalInteractiveShell.interact of
<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7f856c172370>>
565 break
566 except KeyboardInterrupt as e:
567 print("\n%s escaped interact()\n" % type(e).__name__)
568 finally:
569 # An interrupt during the eventloop will mess up the
570 # internal state of the prompt_toolkit library.
571 # Stopping the eventloop fixes this, see
572 # https://github.com/ipython/ipython/pull/9867
573 if hasattr(self, '_eventloop'):
574 self._eventloop.stop()
575
576 self.restore_term_title()
577
578
579 _inputhook = None
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py
in interact(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>,
display_banner=<object object>)
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)
541
542 self.keep_running = True
543 while self.keep_running:
544 print(self.separate_in, end='')
545
546 try:
--> 547 code = self.prompt_for_code()
code = 'ls'
self.prompt_for_code = <bound method
TerminalInteractiveShell.prompt_for_code of
<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7f856c172370>>
548 except EOFError:
549 if (not self.confirm_exit) \
550 or self.ask_yes_no('Do you really want to exit
([y]/n)?','y','n'):
551 self.ask_exit()
552
553 else:
554 if code:
555 self.run_cell(code, store_history=True)
556
557 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
558 # An extra layer of protection in case someone mashing Ctrl-C
breaks
559 # out of our internal code.
560 if display_banner is not DISPLAY_BANNER_DEPRECATED:
561 warn('mainloop `display_banner` argument is deprecated
since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning,
stacklevel=2)
562 while True:
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py
in prompt_for_code(self=<sage.repl.interpreter.SageTerminalInteractiveShell
object>)
458 # In order to make sure that asyncio code written in the
459 # interactive shell doesn't interfere with the prompt, we run
the
460 # prompt in a different event loop.
461 # If we don't do this, people could spawn coroutine with a
462 # while/true inside which will freeze the prompt.
463
464 try:
465 old_loop = asyncio.get_event_loop()
466 except RuntimeError:
467 # This happens when the user used `asyncio.run()`.
468 old_loop = None
469
470 asyncio.set_event_loop(self.pt_loop)
471 try:
472 with patch_stdout(raw=True):
--> 473 text = self.pt_app.prompt(
text = undefined
self.pt_app.prompt = <bound method PromptSession.prompt of
<prompt_toolkit.shortcuts.prompt.PromptSession object at 0x7f856c700a00>>
default = ''
self._extra_prompt_options = <bound method
TerminalInteractiveShell._extra_prompt_options of
<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7f856c172370>>
474 default=default,
475 **self._extra_prompt_options())
476 finally:
477 # Restore the original event loop.
478 asyncio.set_event_loop(old_loop)
479
480 return text
481
482 def enable_win_unicode_console(self):
483 # Since IPython 7.10 doesn't support python < 3.6 and PEP 528,
Python uses the unicode APIs for the Windows
484 # console by default, so WUC shouldn't be needed.
485 from warnings import warn
486 warn("`enable_win_unicode_console` is deprecated since IPython
7.10, does not do anything and will be removed in the future",
487 DeprecationWarning,
488 stacklevel=2)
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py
in prompt(self=<prompt_toolkit.shortcuts.prompt.PromptSession object>,
message=<prompt_toolkit.formatted_text.pygments.PygmentsTokens object>,
editing_mode=None, refresh_interval=None, vi_mode=None,
lexer=<IPython.terminal.ptutils.IPythonPTLexer object>, completer=None,
complete_in_thread=False, is_password=None, key_bindings=None,
bottom_toolbar=None, style=None, color_depth=None,
include_default_pygments_style=None, style_transformation=None,
swap_light_and_dark_colors=None, rprompt=None, multiline=True,
prompt_continuation=<function
TerminalInteractiveShell._extra_prompt_options.<locals>.<lambda>>,
wrap_lines=None, enable_history_search=None, search_ignore_case=None,
complete_while_typing=None, validate_while_typing=None,
complete_style=<CompleteStyle.MULTI_COLUMN: 'MULTI_COLUMN'>, auto_suggest=None,
validator=None, clipboard=None, mouse_support=None,
input_processors=[ConditionalProcessor(processor=<prompt_toolkit.l...pt_options.<locals>.<lambda>
at 0x7f8571a87dc0>))], placeholder=None, reserve_space_for_menu=6,
enable_system_prompt=None, enable_suspend=None, enable_open_in_editor=None,
tempfile_suffix=None, tempfile=None, default='', accept_default=False,
pre_run=None, set_exception_handler=True)
998 self.tempfile_suffix = tempfile_suffix
999 if tempfile is not None:
1000 self.tempfile = tempfile
1001
1002 self._add_pre_run_callables(pre_run, accept_default)
1003 self.default_buffer.reset(
1004 default if isinstance(default, Document) else
Document(default)
1005 )
1006 self.app.refresh_interval = self.refresh_interval # This is
not reactive.
1007
1008 # If we are using the default output, and have a dumb terminal.
Use the
1009 # dumb prompt.
1010 if self._output is None and is_dumb_terminal():
1011 return
get_event_loop().run_until_complete(self._dumb_prompt(self.message))
1012
-> 1013 return self.app.run(set_exception_handler=set_exception_handler)
self.app.run = <bound method Application.run of
<prompt_toolkit.application.application.Application object at 0x7f856c76c880>>
set_exception_handler = True
1014
1015 async def _dumb_prompt(self, message: AnyFormattedText = "") -> _T:
1016 """
1017 Prompt function for dumb terminals.
1018
1019 Dumb terminals have minimum rendering capabilities. We can only
print
1020 text to the screen. We can't use colors, and we can't do cursor
1021 movements. The Emacs inferior shell is an example of a dumb
terminal.
1022
1023 We will show the prompt, and wait for the input. We still
handle arrow
1024 keys, and all custom key bindings, but we don't really render
the
1025 cursor movements. Instead we only print the typed character
that's
1026 right before the cursor.
1027 """
1028 # Send prompt to output.
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/application/application.py
in run(self=<prompt_toolkit.application.application.Application object>,
pre_run=None, set_exception_handler=True)
801 """
802 # We don't create a new event loop by default, because we want
to be
803 # sure that when this is called multiple times, each call of
`run()`
804 # goes through the same event loop. This way, users can schedule
805 # background-tasks that keep running across multiple prompts.
806 try:
807 loop = get_event_loop()
808 except RuntimeError:
809 # Possibly we are not running in the main thread, where no
event
810 # loop is set by default. Or somebody called `asyncio.run()`
811 # before, which closes the existing event loop. We can
create a new
812 # loop.
813 loop = new_event_loop()
814 set_event_loop(loop)
815
--> 816 return loop.run_until_complete(
loop.run_until_complete = <bound method
BaseEventLoop.run_until_complete of <_UnixSelectorEventLoop running=False
closed=False debug=False>>
self.run_async = <bound method Application.run_async of
<prompt_toolkit.application.application.Application object at 0x7f856c76c880>>
pre_run = None
set_exception_handler = True
817 self.run_async(pre_run=pre_run,
set_exception_handler=set_exception_handler)
818 )
819
820 def _handle_exception(
821 self, loop: AbstractEventLoop, context: Dict[str, Any]
822 ) -> None:
823 """
824 Handler for event loop exceptions.
825 This will print the exception, using run_in_terminal.
826 """
827 # For Python 2: we have to get traceback at this point, because
828 # we're still in the 'except:' block of the event loop where the
829 # traceback is still available. Moving this code in the
830 # 'print_exception' coroutine will loose the exception.
831 tb = get_traceback_from_context(context)
/opt/miniconda3/envs/sage/lib/python3.8/asyncio/base_events.py in
run_until_complete(self=<_UnixSelectorEventLoop running=False closed=False
debug=False>, future=<Task finished name='Task-20'
coro=<Application....exception=NameError("name 'sys' is not defined")>)
601 future.add_done_callback(_run_until_complete_cb)
602 try:
603 self.run_forever()
604 except:
605 if new_task and future.done() and not future.cancelled():
606 # The coroutine raised a BaseException. Consume the
exception
607 # to not log a warning, the caller doesn't have access
to the
608 # local task.
609 future.exception()
610 raise
611 finally:
612 future.remove_done_callback(_run_until_complete_cb)
613 if not future.done():
614 raise RuntimeError('Event loop stopped before Future
completed.')
615
--> 616 return future.result()
future.result = <built-in method result of _asyncio.Task object at
0x7f8571a617c0>
617
618 def stop(self):
619 """Stop running the event loop.
620
621 Every callback already scheduled will still run. This simply
informs
622 run_forever to stop looping after a complete iteration.
623 """
624 self._stopping = True
625
626 def close(self):
627 """Close the event loop.
628
629 This clears the queues and shuts down the executor,
630 but does not wait for the executor to finish.
631
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/application/application.py
in run_async(self=<prompt_toolkit.application.application.Application object>,
pre_run=None, set_exception_handler=True)
768 # go in the finally! If `_run_async` raises
769 # `KeyboardInterrupt`, we still want to wait
for the
770 # background tasks.
771 await
self.cancel_and_wait_for_background_tasks()
772
773 # Set the `_is_running` flag to `False`.
Normally this
774 # happened already in the finally block in
`run_async`
775 # above, but in case of exceptions, that's not
always the
776 # case.
777 self._is_running = False
778 return result
779 finally:
780 if set_exception_handler:
781 loop.set_exception_handler(previous_exc_handler)
782
--> 783 return await _run_async2()
_run_async2 = <function Application.run_async.<locals>._run_async2 at
0x7f856c7de790>
784
785 def run(
786 self,
787 pre_run: Optional[Callable[[], None]] = None,
788 set_exception_handler: bool = True,
789 ) -> _AppResult:
790 """
791 A blocking 'run' call that waits until the UI is finished.
792
793 This will start the current asyncio event loop. If no loop is
set for
794 the current thread, then it will create a new loop.
795
796 :param pre_run: Optional callable, which is called right after
the
797 "reset" of the application.
798 :param set_exception_handler: When set, in case of an
exception, go out
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/application/application.py
in _run_async2()
756
757 loop = get_event_loop()
758 if set_exception_handler:
759 previous_exc_handler = loop.get_exception_handler()
760 loop.set_exception_handler(self._handle_exception)
761
762 try:
763 with set_app(self):
764 try:
765 result = await _run_async()
766 finally:
767 # Wait for the background tasks to be done.
This needs to
768 # go in the finally! If `_run_async` raises
769 # `KeyboardInterrupt`, we still want to wait
for the
770 # background tasks.
--> 771 await
self.cancel_and_wait_for_background_tasks()
global self.cancel_and_wait_for_background_tasks = undefined
772
773 # Set the `_is_running` flag to `False`.
Normally this
774 # happened already in the finally block in
`run_async`
775 # above, but in case of exceptions, that's not
always the
776 # case.
777 self._is_running = False
778 return result
779 finally:
780 if set_exception_handler:
781 loop.set_exception_handler(previous_exc_handler)
782
783 return await _run_async2()
784
785 def run(
786 self,
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/application/application.py
in
cancel_and_wait_for_background_tasks(self=<prompt_toolkit.application.application.Application
object>)
857
858 async def cancel_and_wait_for_background_tasks(self) -> None:
859 """
860 Cancel all background tasks, and wait for the cancellation to
be done.
861 If any of the background tasks raised an exception, this will
also
862 propagate the exception.
863
864 (If we had nurseries like Trio, this would be the `__aexit__`
of a
865 nursery.)
866 """
867 for task in self.background_tasks:
868 task.cancel()
869
870 for task in self.background_tasks:
871 try:
--> 872 await task
task = <Task finished name='Task-100'
coro=<Buffer._create_completer_coroutine.<locals>.async_completer() done,
defined at
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/buffer.py:1841>
exception=NameError("name 'sys' is not defined")>
873 except CancelledError:
874 pass
875
876 def cpr_not_supported_callback(self) -> None:
877 """
878 Called when we don't receive the cursor position response in
time.
879 """
880 if not self.output.responds_to_cpr:
881 return # We know about this already.
882
883 def in_terminal() -> None:
884 self.output.write(
885 "WARNING: your terminal doesn't support cursor position
requests (CPR).\r\n"
886 )
887 self.output.flush()
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/buffer.py
in new_coroutine(*a=(), **kw={'complete_event':
CompleteEvent(text_inserted=False, completion_requested=True),
'insert_common_part': True, 'select_first': False, 'select_last': False})
1839 running = False
1840
1841 @wraps(coroutine)
1842 async def new_coroutine(*a: Any, **kw: Any) -> Any:
1843 nonlocal running
1844
1845 # Don't start a new function, if the previous is still in
progress.
1846 if running:
1847 return
1848
1849 running = True
1850
1851 try:
1852 while True:
1853 try:
-> 1854 await coroutine(*a, **kw)
global coroutine = undefined
a = ()
kw = {'select_first': False, 'select_last': False,
'insert_common_part': True, 'complete_event':
CompleteEvent(text_inserted=False, completion_requested=True)}
1855 except _Retry:
1856 continue
1857 else:
1858 return None
1859 finally:
1860 running = False
1861
1862 return cast(_T, new_coroutine)
1863
1864
1865 class _Retry(Exception):
1866 " Retry in `_only_one_at_a_time`. "
1867
1868
1869 def indent(buffer: Buffer, from_row: int, to_row: int, count: int = 1)
-> None:
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/buffer.py
in async_completer(select_first=False, select_last=False,
insert_common_part=True, complete_event=CompleteEvent(text_inserted=False,
completion_requested=True))
1668 complete_event = complete_event or
CompleteEvent(text_inserted=True)
1669
1670 # Don't complete when we already have completions.
1671 if self.complete_state or not self.completer:
1672 return
1673
1674 # Create an empty CompletionState.
1675 complete_state =
CompletionState(original_document=self.document)
1676 self.complete_state = complete_state
1677
1678 def proceed() -> bool:
1679 """Keep retrieving completions. Input text has not yet
changed
1680 while generating completions."""
1681 return self.complete_state == complete_state
1682
-> 1683 async for completion in
self.completer.get_completions_async(
completion = undefined
global self.completer.get_completions_async = undefined
document = Document('cd Do', 5)
complete_event = CompleteEvent(text_inserted=False,
completion_requested=True)
1684 document, complete_event
1685 ):
1686 complete_state.completions.append(completion)
1687 self.on_completions_changed.fire()
1688
1689 # If the input text changes, abort.
1690 if not proceed():
1691 break
1692
1693 completions = complete_state.completions
1694
1695 # When there is only one completion, which has nothing to
add, ignore it.
1696 if len(completions) == 1 and completion_does_nothing(
1697 document, completions[0]
1698 ):
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/completion/base.py
in get_completions_async(self=DynamicCompleter(<function
PromptSession._create...ils.IPythonPTCompleter object at 0x7f856c499760>),
document=Document('cd Do', 5),
complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
254
255 def __init__(self, get_completer: Callable[[],
Optional[Completer]]) -> None:
256 self.get_completer = get_completer
257
258 def get_completions(
259 self, document: Document, complete_event: CompleteEvent
260 ) -> Iterable[Completion]:
261 completer = self.get_completer() or DummyCompleter()
262 return completer.get_completions(document, complete_event)
263
264 async def get_completions_async(
265 self, document: Document, complete_event: CompleteEvent
266 ) -> AsyncGenerator[Completion, None]:
267 completer = self.get_completer() or DummyCompleter()
268
--> 269 async for completion in completer.get_completions_async(
completion = undefined
completer.get_completions_async = <bound method
Completer.get_completions_async of <IPython.terminal.ptutils.IPythonPTCompleter
object at 0x7f856c499760>>
document = Document('cd Do', 5)
complete_event = CompleteEvent(text_inserted=False,
completion_requested=True)
270 document, complete_event
271 ):
272 yield completion
273
274 def __repr__(self) -> str:
275 return "DynamicCompleter(%r -> %r)" % (self.get_completer,
self.get_completer())
276
277
278 class _MergedCompleter(Completer):
279 """
280 Combine several completers into one.
281 """
282
283 def __init__(self, completers: Sequence[Completer]) -> None:
284 self.completers = completers
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/prompt_toolkit/completion/base.py
in get_completions_async(self=<IPython.terminal.ptutils.IPythonPTCompleter
object>, document=Document('cd Do', 5),
complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
181 :param document: :class:`~prompt_toolkit.document.Document`
instance.
182 :param complete_event: :class:`.CompleteEvent` instance.
183 """
184 while False:
185 yield
186
187 async def get_completions_async(
188 self, document: Document, complete_event: CompleteEvent
189 ) -> AsyncGenerator[Completion, None]:
190 """
191 Asynchronous generator for completions. (Probably, you won't
have to
192 override this.)
193
194 Asynchronous generator of :class:`.Completion` objects.
195 """
--> 196 for item in self.get_completions(document, complete_event):
item = undefined
self.get_completions = <bound method IPythonPTCompleter.get_completions
of <IPython.terminal.ptutils.IPythonPTCompleter object at 0x7f856c499760>>
document = Document('cd Do', 5)
complete_event = CompleteEvent(text_inserted=False,
completion_requested=True)
197 yield item
198
199
200 class ThreadedCompleter(Completer):
201 """
202 Wrapper that runs the `get_completions` generator in a thread.
203
204 (Use this to prevent the user interface from becoming unresponsive
if the
205 generation of completions takes too much time.)
206
207 The completions will be displayed as soon as they are produced. The
user
208 can already select a completion, even if not all completions are
displayed.
209 """
210
211 def __init__(self, completer: Completer) -> None:
/opt/miniconda3/envs/sage/lib/python3.8/site-packages/IPython/terminal/ptutils.py
in get_completions(self=<IPython.terminal.ptutils.IPythonPTCompleter object>,
document=Document('cd Do', 5),
complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
101 return
102 # Some bits of our completion system may print stuff (e.g. if a
module
103 # is imported). This context manager ensures that doesn't
interfere with
104 # the prompt.
105
106 with patch_stdout(), provisionalcompleter():
107 body = document.text
108 cursor_row = document.cursor_position_row
109 cursor_col = document.cursor_position_col
110 cursor_position = document.cursor_position
111 offset = cursor_to_position(body, cursor_row, cursor_col)
112 try:
113 yield from self._get_completions(body, offset,
cursor_position, self.ipy_completer)
114 except Exception as e:
115 try:
--> 116 exc_type, exc_value, exc_tb = sys.exc_info()
exc_type = undefined
exc_value = undefined
exc_tb = undefined
global sys.exc_info = undefined
117 traceback.print_exception(exc_type, exc_value,
exc_tb)
118 except AttributeError:
119 print('Unrecoverable Error in completions')
120
121 @staticmethod
122 def _get_completions(body, offset, cursor_position, ipyc):
123 """
124 Private equivalent of get_completions() use only for
unit_testing.
125 """
126 debug = getattr(ipyc, 'debug', False)
127 completions = _deduplicate_completions(
128 body, ipyc.completions(body, offset))
129 for c in completions:
130 if not c.text:
131 # Guard against completion machinery giving us an empty
string.
NameError: name 'sys' is not defined
***************************************************************************
History of session input:get_ipython().run_line_magic('ls', '')
*** Last line of input (may not be in above history):
ls