用于IPython的Powerline插件会导致其在版本7.0.0和7.0.1的启动时崩溃; 它适用于IPython 6.5.0版本。 我将附上详细的崩溃报告作为注释。 以下是我的IPython配置:
# Enable the Powerline prompt
from powerline.bindings.ipython.since_5 import PowerlinePrompts
c.TerminalInteractiveShell.simple_prompt = False
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
## Shortcut style to use at the prompt. 'vi' or 'emacs'.
c.TerminalInteractiveShell.editing_mode = 'vi'
## Set the editor used by IPython (default to $EDITOR/vi/notepad).
c.TerminalInteractiveShell.editor = 'vim'
c.TerminalInteractiveShell.highlighting_style = 'monokai'
$ ipython master| ✔
Python 3.6.6 (default, Oct 3 2018, 13:39:52)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.0.1 -- An enhanced Interactive Python. Type '?' for help.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
TypeErrorPython 3.6.6: /home/local/ANT/dylone/.pyenv/versions/3.6.6/bin/python3.6
Fri Oct 5 12:15:31 2018
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.
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _run_async2()
650 f = From(_run_async())
--> 651 result = yield f
result = undefined
f = <prompt_toolkit.eventloop.future.Future object at 0x7f06ce70c240>
652 finally:
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py in step_next(f=None)
85 if f is None:
---> 86 new_f = coroutine.send(None)
global new_f = undefined
global coroutine.send = undefined
87 else:
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _run_async()
593 self._request_absolute_cursor_position()
--> 594 self._redraw()
global self._redraw = undefined
595
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _redraw(self=<prompt_toolkit.application.application.Application object>, render_as_done=False)
442 else:
--> 443 self.renderer.render(self, self.layout)
self.renderer.render = <bound method Renderer.render of <prompt_toolkit.renderer.Renderer object at 0x7f06ce5eb320>>
self = <prompt_toolkit.application.application.Application object at 0x7f06ce749710>
self.layout = Layout(<prompt_toolkit.layout.containers.HSplit object at 0x7f06ce736e48>, current_window=Window(content=<BufferControl buffer=<Buffer(name='DEFAULT_BUFFER', text='') at 139667210131160> at 139667210247472>))
444
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/renderer.py in render(self=<prompt_toolkit.renderer.Renderer object>, app=<prompt_toolkit.application.application.Application object>, layout=Layout(<prompt_toolkit.layout.containers.HSplit ...ext='') at 139667210131160> at 139667210247472>)), is_done=False)
549 # (But note that we still use _last_screen to calculate the height.)
--> 550 if (self.style.invalidation_hash() != self._last_style_hash or
self.style.invalidation_hash = <bound method _MergedStyle.invalidation_hash of <prompt_toolkit.styles.style._MergedStyle object at 0x7f06ce5eb208>>
self._last_style_hash = None
app.style_transformation.invalidation_hash = <bound method _MergedStyleTransformation.invalidation_hash of <prompt_toolkit.styles.style_transformation._MergedStyleTransformation object at 0x7f06ce7490b8>>
self._last_transformation_hash = None
app.color_depth = 'DEPTH_8_BIT'
self._last_color_depth = None
551 app.style_transformation.invalidation_hash() != self._last_transformation_hash or
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/style.py in invalidation_hash(self=<prompt_toolkit.styles.style._MergedStyle object>)
371 def invalidation_hash(self):
--> 372 return tuple(s.invalidation_hash() for s in self.styles)
global tuple = undefined
global s.invalidation_hash = undefined
global s = undefined
self.styles = [<prompt_toolkit.styles.style._MergedStyle object at 0x7f06ce6538d0>, <prompt_toolkit.styles.base.DynamicStyle object at 0x7f06ce63ea90>, <prompt_toolkit.styles.base.DynamicStyle object at 0x7f06ce5eb2b0>]
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/style.py in <genexpr>(.0=<list_iterator object>)
371 def invalidation_hash(self):
--> 372 return tuple(s.invalidation_hash() for s in self.styles)
global tuple = undefined
s.invalidation_hash = <bound method DynamicStyle.invalidation_hash of <prompt_toolkit.styles.base.DynamicStyle object at 0x7f06ce5eb2b0>>
s = <prompt_toolkit.styles.base.DynamicStyle object at 0x7f06ce5eb2b0>
global self.styles = undefined
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/base.py in invalidation_hash(self=<prompt_toolkit.styles.base.DynamicStyle object>)
139 def invalidation_hash(self):
--> 140 return (self.get_style() or self._dummy).invalidation_hash()
self.get_style = <function Application._create_merged_style.<locals>.<lambda> at 0x7f06ce63b730>
self._dummy.invalidation_hash = <bound method DummyStyle.invalidation_hash of <prompt_toolkit.styles.base.DummyStyle object at 0x7f06ce5eb278>>
141
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/base.py in invalidation_hash(self=<prompt_toolkit.styles.base.DynamicStyle object>)
139 def invalidation_hash(self):
--> 140 return (self.get_style() or self._dummy).invalidation_hash()
self.get_style = <function PromptSession._create_application.<locals>.<lambda> at 0x7f06ce660598>
self._dummy.invalidation_hash = <bound method DummyStyle.invalidation_hash of <prompt_toolkit.styles.base.DummyStyle object at 0x7f06ce748e80>>
141
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/base.py in invalidation_hash(self=<prompt_toolkit.styles.base.DynamicStyle object>)
139 def invalidation_hash(self):
--> 140 return (self.get_style() or self._dummy).invalidation_hash()
self.get_style = <function TerminalInteractiveShell.init_prompt_toolkit_cli.<locals>.<lambda> at 0x7f06ce832bf8>
self._dummy.invalidation_hash = <bound method DummyStyle.invalidation_hash of <prompt_toolkit.styles.base.DummyStyle object at 0x7f06ce821630>>
141
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/powerline/renderers/ipython/since_5.py in invalidation_hash(self=<powerline.renderers.ipython.since_5.PowerlinePromptStyle object>)
78 def invalidation_hash(self):
---> 79 return super(PowerlinePromptStyle, self).invalidation_hash() + 1
global super = undefined
global PowerlinePromptStyle = <class 'powerline.renderers.ipython.since_5.PowerlinePromptStyle'>
self.invalidation_hash = <bound method PowerlinePromptStyle.invalidation_hash of <powerline.renderers.ipython.since_5.PowerlinePromptStyle object at 0x7f06ce5f8cf8>>
80
TypeError: can only concatenate tuple (not "int") to tuple
During handling of the above exception, another exception occurred:
---------------------------------------------------------------------------
AssertionErrorPython 3.6.6: /home/local/ANT/dylone/.pyenv/versions/3.6.6/bin/python3.6
Fri Oct 5 12:15:31 2018
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.
~/.pyenv/versions/3.6.6/bin/ipython in <module>
1 #!/home/local/ANT/dylone/.pyenv/versions/3.6.6/bin/python3.6
2
3 # -*- coding: utf-8 -*-
4 import re
5 import sys
6
7 from IPython import start_ipython
8
9 if __name__ == '__main__':
10 sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
---> 11 sys.exit(start_ipython())
global sys.exit = <built-in function exit>
global start_ipython = <function start_ipython at 0x7f06cf554378>
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/__init__.py in start_ipython(argv=None, **kwargs={})
110 This is a public API method, and will survive implementation changes.
111
112 Parameters
113 ----------
114
115 argv : list or None, optional
116 If unspecified or None, IPython will parse command-line options from sys.argv.
117 To prevent any command-line parsing, pass an empty list: `argv=[]`.
118 user_ns : dict, optional
119 specify this dictionary to initialize the IPython user namespace with particular values.
120 kwargs : various, optional
121 Any other kwargs will be passed to the Application constructor,
122 such as `config`.
123 """
124 from IPython.terminal.ipapp import launch_new_instance
--> 125 return launch_new_instance(argv=argv, **kwargs)
launch_new_instance = <bound method Application.launch_instance of <class 'IPython.terminal.ipapp.TerminalIPythonApp'>>
argv = None
kwargs = {}
126
127 def start_kernel(argv=None, **kwargs):
128 """Launch a normal IPython kernel instance (as opposed to embedded)
129
130 `IPython.embed_kernel()` puts a shell in a particular calling scope,
131 such as a function or method for debugging purposes,
132 which is often not desirable.
133
134 `start_kernel()` does full, regular IPython initialization,
135 including loading startup files, configuration, etc.
136 much of which is skipped by `embed()`.
137
138 Parameters
139 ----------
140
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/traitlets/config/application.py in launch_instance(cls=<class 'IPython.terminal.ipapp.TerminalIPythonApp'>, argv=None, **kwargs={})
643 lines.append(cls.class_config_section())
644 return '\n'.join(lines)
645
646 def exit(self, exit_status=0):
647 self.log.debug("Exiting application: %s" % self.name)
648 sys.exit(exit_status)
649
650 <strong i="5">@classmethod</strong>
651 def launch_instance(cls, argv=None, **kwargs):
652 """Launch a global instance of this Application
653
654 If a global instance already exists, this reinitializes and starts it
655 """
656 app = cls.instance(**kwargs)
657 app.initialize(argv)
--> 658 app.start()
app.start = <bound method TerminalIPythonApp.start of <IPython.terminal.ipapp.TerminalIPythonApp object at 0x7f06d6aae080>>
659
660 #-----------------------------------------------------------------------------
661 # utility functions, for convenience
662 #-----------------------------------------------------------------------------
663
664 def boolean_flag(name, configurable, set_help='', unset_help=''):
665 """Helper for building basic --trait, --no-trait flags.
666
667 Parameters
668 ----------
669
670 name : str
671 The name of the flag.
672 configurable : str
673 The 'Class.trait' string of the trait to be set/unset with the flag
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/terminal/ipapp.py in start(self=<IPython.terminal.ipapp.TerminalIPythonApp 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 <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f06d25a8a20>>
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()
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in mainloop(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=<object object>)
457 if (not self.confirm_exit) \
458 or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
459 self.ask_exit()
460
461 else:
462 if code:
463 self.run_cell(code, store_history=True)
464
465 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
466 # An extra layer of protection in case someone mashing Ctrl-C breaks
467 # out of our internal code.
468 if display_banner is not DISPLAY_BANNER_DEPRECATED:
469 warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
470 while True:
471 try:
--> 472 self.interact()
self.interact = <bound method TerminalInteractiveShell.interact of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f06d25a8a20>>
473 break
474 except KeyboardInterrupt as e:
475 print("\n%s escaped interact()\n" % type(e).__name__)
476 finally:
477 # An interrupt during the eventloop will mess up the
478 # internal state of the prompt_toolkit library.
479 # Stopping the eventloop fixes this, see
480 # https://github.com/ipython/ipython/pull/9867
481 if hasattr(self, '_eventloop'):
482 self._eventloop.stop()
483
484 _inputhook = None
485 def inputhook(self, context):
486 if self._inputhook is not None:
487 self._inputhook(context)
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in interact(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=<object object>)
440 def ask_exit(self):
441 self.keep_running = False
442
443 rl_next_input = None
444
445 def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
446
447 if display_banner is not DISPLAY_BANNER_DEPRECATED:
448 warn('interact `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
449
450 self.keep_running = True
451 while self.keep_running:
452 print(self.separate_in, end='')
453
454 try:
--> 455 code = self.prompt_for_code()
code = undefined
self.prompt_for_code = <bound method TerminalInteractiveShell.prompt_for_code of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f06d25a8a20>>
456 except EOFError:
457 if (not self.confirm_exit) \
458 or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
459 self.ask_exit()
460
461 else:
462 if code:
463 self.run_cell(code, store_history=True)
464
465 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
466 # An extra layer of protection in case someone mashing Ctrl-C breaks
467 # out of our internal code.
468 if display_banner is not DISPLAY_BANNER_DEPRECATED:
469 warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
470 while True:
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in prompt_for_code(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>)
369 Condition(lambda: self.highlight_matching_brackets))],
370 'inputhook': self.inputhook,
371 }
372
373 def prompt_for_code(self):
374 if self.rl_next_input:
375 default = self.rl_next_input
376 self.rl_next_input = None
377 else:
378 default = ''
379
380 with patch_stdout(raw=True):
381 text = self.pt_app.prompt(
382 default=default,
383 # pre_run=self.pre_prompt,# reset_current_buffer=True,
--> 384 **self._extra_prompt_options())
self._extra_prompt_options = <bound method TerminalInteractiveShell._extra_prompt_options of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f06d25a8a20>>
385 return text
386
387 def enable_win_unicode_console(self):
388 if sys.version_info >= (3, 6):
389 # Since PEP 528, Python uses the unicode APIs for the Windows
390 # console by default, so WUC shouldn't be needed.
391 return
392
393 import win_unicode_console
394 win_unicode_console.enable()
395
396 def init_io(self):
397 if sys.platform not in {'win32', 'cli'}:
398 return
399
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/shortcuts/prompt.py in prompt(self=<prompt_toolkit.shortcuts.prompt.PromptSession object>, message=<function TerminalInteractiveShell._extra_prompt_options.<locals>.get_message>, default='', 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='MULTI_COLUMN', auto_suggest=None, validator=None, clipboard=None, mouse_support=None, input_processors=[ConditionalProcessor(processor=<prompt_toolkit.l...pt_options.<locals>.<lambda> at 0x7f06ce63bea0>))], reserve_space_for_menu=6, enable_system_prompt=None, enable_suspend=None, enable_open_in_editor=None, tempfile_suffix=None, inputhook=<bound method TerminalInteractiveShell.inputhook...nteractiveshell.TerminalInteractiveShell object>>, async_=False, accept_default=False, pre_run=None)
716
717 def run_sync():
718 with self._auto_refresh_context():
719 self.default_buffer.reset(Document(self.default))
720 return self.app.run(inputhook=self.inputhook, pre_run=pre_run2)
721
722 def run_async():
723 with self._auto_refresh_context():
724 self.default_buffer.reset(Document(self.default))
725 result = yield From(self.app.run_async(pre_run=pre_run2))
726 raise Return(result)
727
728 if async_:
729 return ensure_future(run_async())
730 else:
--> 731 return run_sync()
run_sync = <function PromptSession.prompt.<locals>.run_sync at 0x7f06ce832c80>
732
733 <strong i="6">@property</strong>
734 def editing_mode(self):
735 return self.app.editing_mode
736
737 @editing_mode.setter
738 def editing_mode(self, value):
739 self.app.editing_mode = value
740
741 def _get_default_buffer_control_height(self):
742 # If there is an autocompletion menu to be shown, make sure that our
743 # layout has at least a minimal height in order to display it.
744 if (self.completer is not None and
745 self.complete_style != CompleteStyle.READLINE_LIKE):
746 space = self.reserve_space_for_menu
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/shortcuts/prompt.py in run_sync()
705 def pre_run2():
706 if pre_run:
707 pre_run()
708
709 if accept_default:
710 # Validate and handle input. We use `call_from_executor` in
711 # order to run it "soon" (during the next iteration of the
712 # event loop), instead of right now. Otherwise, it won't
713 # display the default value.
714 get_event_loop().call_from_executor(
715 self.default_buffer.validate_and_handle)
716
717 def run_sync():
718 with self._auto_refresh_context():
719 self.default_buffer.reset(Document(self.default))
--> 720 return self.app.run(inputhook=self.inputhook, pre_run=pre_run2)
global self.app.run = undefined
global inputhook = undefined
global self.inputhook = undefined
global pre_run = undefined
global pre_run2 = undefined
721
722 def run_async():
723 with self._auto_refresh_context():
724 self.default_buffer.reset(Document(self.default))
725 result = yield From(self.app.run_async(pre_run=pre_run2))
726 raise Return(result)
727
728 if async_:
729 return ensure_future(run_async())
730 else:
731 return run_sync()
732
733 <strong i="7">@property</strong>
734 def editing_mode(self):
735 return self.app.editing_mode
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in run(self=<prompt_toolkit.application.application.Application object>, pre_run=<function PromptSession.prompt.<locals>.pre_run2>, set_exception_handler=True, inputhook=<bound method TerminalInteractiveShell.inputhook...nteractiveshell.TerminalInteractiveShell object>>)
683 def print_exception():
684 # Print output. Similar to 'loop.default_exception_handler',
685 # but don't use logger. (This works better on Python 2.)
686 print('\nUnhandled exception in event loop:')
687 print(formatted_tb)
688 print('Exception %s' % (context.get('exception'), ))
689
690 yield From(_do_wait_for_enter('Press ENTER to continue...'))
691 run_coroutine_in_terminal(print_exception)
692
693 if set_exception_handler:
694 # Run with patched exception handler.
695 previous_exc_handler = loop.get_exception_handler()
696 loop.set_exception_handler(handle_exception)
697 try:
--> 698 return run()
run = <function Application.run.<locals>.run at 0x7f06ce5f9158>
699 finally:
700 loop.set_exception_handler(previous_exc_handler)
701 else:
702 run()
703
704 def cpr_not_supported_callback(self):
705 """
706 Called when we don't receive the cursor position response in time.
707 """
708 if not self.input.responds_to_cpr:
709 return # We know about this already.
710
711 def in_terminal():
712 self.output.write(
713 "WARNING: your terminal doesn't support cursor position requests (CPR).\r\n")
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in run()
657
658 def run(self, pre_run=None, set_exception_handler=True, inputhook=None):
659 """
660 A blocking 'run' call that waits until the UI is finished.
661
662 :param set_exception_handler: When set, in case of an exception, go out
663 of the alternate screen and hide the application, display the
664 exception, and wait for the user to press ENTER.
665 :param inputhook: None or a callable that takes an `InputHookContext`.
666 """
667 loop = get_event_loop()
668
669 def run():
670 f = self.run_async(pre_run=pre_run)
671 run_until_complete(f, inputhook=inputhook)
--> 672 return f.result()
f.result = <bound method Future.result of <prompt_toolkit.eventloop.future.Future object at 0x7f06ce718978>>
673
674 def handle_exception(context):
675 " Print the exception, using run_in_terminal. "
676 # For Python 2: we have to get traceback at this point, because
677 # we're still in the 'except:' block of the event loop where the
678 # traceback is still available. Moving this code in the
679 # 'print_exception' coroutine will loose the exception.
680 tb = get_traceback_from_context(context)
681 formatted_tb = ''.join(format_tb(tb))
682
683 def print_exception():
684 # Print output. Similar to 'loop.default_exception_handler',
685 # but don't use logger. (This works better on Python 2.)
686 print('\nUnhandled exception in event loop:')
687 print(formatted_tb)
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/eventloop/future.py in result(self=<prompt_toolkit.eventloop.future.Future object>)
134 # Activate the original task context (and application) again.
135 with context(self._ctx_id):
136 # They should be called in order.
137 for cb in done_callbacks:
138 cb(self)
139
140 self.loop.call_from_executor(call_them_all)
141
142 def result(self):
143 " Return the result this future represents. "
144 if not self._done:
145 raise InvalidStateError
146
147 self._retrieved_result = True
148 if self._exception:
--> 149 raise self._exception
self._exception = AssertionError()
150 else:
151 return self._result
152
153 def exception(self):
154 " Return the exception that was set on this future. "
155 if not self._done:
156 raise InvalidStateError
157
158 self._retrieved_result = True
159 return self._exception
160
161 def done(self):
162 """
163 Return True if the future is done. Done means either that a result /
164 exception are available, or that the future was cancelled.
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py in step_next(f=<prompt_toolkit.eventloop.future.Future object>)
75 # (If `step_next` had a direct reference to `result_f` and there is a
76 # future that references `step_next`, then sometimes it won't be cleaned up
77 # immediately. - I'm not sure how exactly, but in that case it requires the
78 # garbage collector, because refcounting isn't sufficient.)
79 ref = _FutureRef(result_f)
80
81 # Loop through the generator.
82 def step_next(f=None):
83 " Execute next step of the coroutine."
84 try:
85 if f is None:
86 new_f = coroutine.send(None)
87 else:
88 exc = f.exception()
89 if exc:
---> 90 new_f = coroutine.throw(exc)
global new_f = undefined
global coroutine.throw = undefined
exc = TypeError('can only concatenate tuple (not "int") to tuple',)
91 else:
92 new_f = coroutine.send(f.result())
93 except StopIteration as e:
94 # Stop coroutine. Make sure that a result has been set in the future,
95 # this will call the callbacks. (Also, don't take any result from
96 # StopIteration, it has already been set using `raise Return()`.
97 if not ref.future.done():
98 ref.future.set_result(None)
99 ref.forget()
100 except Return as e:
101 ref.future.set_result(e.value)
102 ref.forget()
103 except BaseException as e:
104 ref.future.set_exception(e)
105 ref.forget()
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _run_async2()
638 if previous_run_in_terminal_f:
639 yield From(previous_run_in_terminal_f)
640
641 # Store unprocessed input as typeahead for next time.
642 store_typeahead(self.input, self.key_processor.empty_queue())
643
644 raise Return(result)
645
646 def _run_async2():
647 self._is_running = True
648 with set_app(self):
649 try:
650 f = From(_run_async())
651 result = yield f
652 finally:
--> 653 assert not self._is_running
global self._is_running = undefined
654 raise Return(result)
655
656 return ensure_future(_run_async2())
657
658 def run(self, pre_run=None, set_exception_handler=True, inputhook=None):
659 """
660 A blocking 'run' call that waits until the UI is finished.
661
662 :param set_exception_handler: When set, in case of an exception, go out
663 of the alternate screen and hide the application, display the
664 exception, and wait for the user to press ENTER.
665 :param inputhook: None or a callable that takes an `InputHookContext`.
666 """
667 loop = get_event_loop()
668
AssertionError:
**********************************************************************
Oops, ipython crashed. We do our best to make it stable, but...
A crash report was automatically generated with the following information:
- A verbatim copy of the crash traceback.
- A copy of your input history during this session.
- Data on your current ipython configuration.
It was left in the file named:
'/home/local/ANT/dylone/.ipython/Crash_report_ipython.txt'
If you can email this file to the developers, the information in it will help
them in understanding and correcting the problem.
You can mail it to: The IPython Development Team at [email protected]
with the subject 'ipython Crash Report'.
If you want to do it now, the following command will work (under Unix):
mail -s 'ipython Crash Report' [email protected] < /home/local/ANT/dylone/.ipython/Crash_report_ipython.txt
In your email, please also include information about:
- The operating system under which the crash happened: Linux, macOS, Windows,
other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2,
Windows 10 Pro), and whether it is 32-bit or 64-bit;
- How ipython was installed: using pip or conda, from GitHub, as part of
a Docker container, or other, providing more detail if possible;
- How to reproduce the crash: what exact sequence of instructions can one
input to get the same crash? Ideally, find a minimal yet complete sequence
of instructions that yields the crash.
To ensure accurate tracking of this issue, please file a report about it at:
https://github.com/ipython/ipython/issues
Hit <Enter> to quit (your terminal may close):
[1] 16729 exit 1 ipython
使用文档的默认配置也会崩溃:
from powerline.bindings.ipython.since_5 import PowerlinePrompts
c = get_config()
c.TerminalInteractiveShell.simple_prompt = False
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
例外:
Traceback (most recent call last):
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 635, in _run_async2
result = yield f
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/eventloop/coroutine.py", line 86, in step_next
new_f = coroutine.send(None)
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 587, in _run_async
self._redraw()
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 436, in _redraw
self.renderer.render(self, self.layout)
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/renderer.py", line 535, in render
if (self.style.invalidation_hash() != self._last_style_hash or
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/style.py", line 371, in invalidation_hash
return tuple(s.invalidation_hash() for s in self.styles)
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/style.py", line 371, in <genexpr>
return tuple(s.invalidation_hash() for s in self.styles)
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/base.py", line 140, in invalidation_hash
return (self.get_style() or self._dummy).invalidation_hash()
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/base.py", line 140, in invalidation_hash
return (self.get_style() or self._dummy).invalidation_hash()
File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/base.py", line 140, in invalidation_hash
return (self.get_style() or self._dummy).invalidation_hash()
File "/usr/local/lib/python3.7/site-packages/powerline/renderers/ipython/since_5.py", line 79, in invalidation_hash
return super(PowerlinePromptStyle, self).invalidation_hash() + 1
TypeError: can only concatenate tuple (not "int") to tuple
所以
ipython>=7.0.0
使用prompt_toolkit>=2.0.0,<2.1.0
ipython<7.0.0
使用prompt_toolkit>=1.0.15,<2.0.0
在hint_toolkit <2.0.0中, invalidation_hash
总是返回str
或int
,但是在最后一个版本中,它可能还会返回tuple
。
作为解决方法,我使用以下方法:
diff --git a/powerline/renderers/ipython/since_5.py b/powerline/renderers/ipython/since_5.py
index 8a26da72..6719fd09 100644
--- a/powerline/renderers/ipython/since_5.py
+++ b/powerline/renderers/ipython/since_5.py
@@ -76,7 +76,7 @@ class PowerlinePromptStyle(DynamicStyle):
return PowerlineStyleDict(fallback)
def invalidation_hash(self):
- return super(PowerlinePromptStyle, self).invalidation_hash() + 1
+ return (h + 1 for h in tuple(super(PowerlinePromptStyle, self).invalidation_hash()))
class IPythonPygmentsRenderer(IPythonRenderer):
但是,我不确定是否值得为此创建公关。 它看起来并不整洁。
创建一个带有适当修复程序的since_7.py
类型文件是否值得?
能做到吗? 这使我无法使用电力线。
上面提到的修复程序可使电源线不崩溃,但不能修复它。 如图所示,显示的提示很难看,在应该改变颜色的任何地方显示“&”。
&
字符似乎是不间断的空格( \xa0
); 通过主题配置禁用它们会将它们替换为普通空格。 但是,颜色似乎仍然没有变化,并且所有内容都具有透明背景,并且#00005f
作为前景色。
我可以确认当前版本的iPython(在本例中为7.4)电源线是否断开。
@Zebradil建议的修复程序使iPython至少可以再次使用(谢谢!),但是-
如前所述-用&代替颜色来装饰提示。
我在IPython 7.3.0中遇到此问题。 必须停止扩展才能使用IPython。
什么时候修好~~~
随时继续。 从@Zebradil的补丁开始,看看
为什么将iPython提示符减少为&s。
您会帮助很多受此错误影响的人。
“用&代替颜色装饰提示”的作用是什么? 看起来像? 我使用补丁,它看起来像下面:
什么都没有 &。
感谢您进一步调查此问题!
什么都没有 &。
在您的情况下,“&”被替换为“ _”-有趣的是,
似乎取决于您使用的系统。
这是Kubuntu 18.04下提示的外观:
&
字符似乎是不间断的空格(\xa0
); 通过主题配置禁用它们会将它们替换为普通空格。 但是,颜色似乎仍然没有变化,并且所有内容都具有透明背景,并且#00005f
作为前景色。
我仍然认为有关&
的问题是另一个问题,与颜色无关。
在您的情况下,“&”被替换为“ _”-有趣的是,
似乎取决于您使用的系统。
它不依赖于系统,而是版本
提示工具包:我从2.0.7升级到2.0.9
现在所有的“&”都是“ _”。
那是/是2.0.8中的新功能:
@acgtyrant是否已安装2.0.9?
对于颜色,似乎忽略了Token.Generic.Prompt
之后的任何内容: https :
据我了解,对于每个突出显示组,都会创建一个新的令牌类型,并且应该在renderers / ipython / since_5.py中定义的自定义DynamicStyle
会创建相应的样式。 但是,似乎没有调用get_attrs_for_token
或get_token_to_attributes_dict
; 查看https://github.com/prompt-toolkit/python-prompt-toolkit/commit/c32f3783a76e6b72d53acda0b6c4a15ef13bed3b会发现,alert_toolkit不再使用get_attrs_for_token
,而是使用get_attrs_for_style_str
。
看来我对颜色问题有(非常棘手的)解决方案:在hl
记录所有使用的突出显示,将它们转换为hint_toolkit-style格式对,并将这些新对附加到通过实现已生成的样式规则中
<strong i="7">@property</strong>
def style_rules(self):
在class PowerlinePromptStyle(DynamicStyle):
。
如您所见,我仍然需要清理代码,但是它似乎可以工作。
@ PH111P-太好了,感谢您潜入兔子洞!
因此,这两个新问题(缺少的颜色和“&” /“ _”)都是由
提示工具包升级到版本2?
因此,这两个新问题(缺少的颜色和“&” /“ _”)都是由
提示工具包升级到版本2?
我想是的,是的。
也许指南“升级到hint_toolkit 2.0”会有所帮助
因为它说明了需要的更改:
https://python-prompt-toolkit.readthedocs.io/zh-CN/master/pages/upgrading.html#pygments -styles-and-token
可以在这里找到颜色修复的实现https://github.com/PH111P/powerline/blob/develop/powerline/renderers/ipython/since_7.py
可以通过在配置文件中禁用它们来解决nbsp的问题(通过设置"use_non_breaking_spaces": false
)。
如果碰巧有时间,我可能会写一个请求请求。
@GHPS我安装了2.0.8-1。
可以在此处找到颜色修复的实现
太好了-您已将其修复。 iPython和Powerline再次可用!
感谢您抽出宝贵的时间整理出来...
您是否有机会复活VI模式指示器
也一样目前不见了...
我添加了颜色修复和配置,但是我的IPython中仍然有_
,我不知道为什么。
我添加了颜色修复和配置,但是我的IPython中仍然有
_
,我不知道为什么。
抱歉,确实不能为此使用配置文件(提到的标志仅在全局主题级别上起作用;就我个人而言,我在源代码中全局禁用了nbsp,但这不应该成为解决方法); 似乎为了修复nbsp,需要更改ipython渲染器,特别是在class IPythonPygmentsRenderer(IPythonRenderer):
添加以下内容应该可以解决此问题。
(这一次我实际上测试了该解决方法,再次对另一件事没有真正起作用感到抱歉;另请参见https://github.com/PH111P/powerline/blob/develop/powerline/renderers/ipython/since_7.py)
def __init__(self, **kwargs):
super(IPythonPygmentsRenderer, self).__init__(**kwargs)
self.character_translations[ord(' ')] = ' '
您是否有机会复活VI模式指示器
也一样目前不见了...
似乎根本就没有该功能的细分市场。 但是,以下内容似乎可以正常工作,可以随时将其转换为完整的段(大多数代码从实际的ipython实现中被无耻地窃取了:https://github.com/ipython/ipython/blob/4f901de17aff2132365fc3741fc5b4b8b9a98dc6 /IPython/terminal/prompts.py#L16):
<strong i="9">@requires_segment_info</strong>
def vi_mode(pl, segment_info):
ipython = segment_info['ipython']._shell
if (getattr(ipython.pt_app, 'editing_mode', None) == 'VI'
and ipython.prompt_includes_vi_mode):
return str(ipython.pt_app.app.vi_state.input_mode)[3:6]
else:
return None
编辑:虽然它似乎确实显示了当前模式,但是它似乎并没有真正更新:/。 我必须承认我并没有在ipython中真正使用vi模式,因此我无法真正测试它。
编辑2 :通过更新绑定进行了修复: https :
@ PH111P-太棒了! 做得好!
在承认Philip(aka @ PH111P )的出色工作的同时,我想提出一个问题,是否可以对--simple-prompt
选项做任何事情:
#!since_5.py
$ ipython
Python 2.7.15+ (default, Nov 27 2018, 23:36:35)
Type "copyright", "credits" or "license" for more information.
IPython 5.8.0.dev -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1] ▶
Do you really want to exit ([y]/n)? y
#!since_7.py
$ ipython3
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.6.0.dev -- An enhanced Interactive Python. Type '?' for help.
In [1] ▶
Do you really want to exit ([y]/n)? y
md5-9ccbec5ae4eaf34d991b332b2f93161f
``` bash
#!since_7.py
$ ipython3 --simple-prompt
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.6.0.dev -- An enhanced Interactive Python. Type '?' for help.
In [1] ▶
公关似乎已经无人值守了一段时间。 有计划更新吗?
据我所知,所有内容( --simple-prompt
除外)似乎都可以正常工作,所以我不确定您指的是@teracamo。 (实际上,PR尚未合并,但这似乎与#2012有关;严格来说,PR仍缺乏测试,但正如我所说,它应该已经可以使用了)
哦,我只是指是否有计划合并此PR,因为当前版本不适用于ipython> = 7.0。
我还没有尝试过PR,所以我不能对--simple-prompt
选项说什么,但是如果没有任何合并计划,我会做。
@alabamagan https://github.com/powerline/powerline/pull/2048怎么样?
在发布更改之前,请先检出develop
分支以获取更改。 它可能不如master
稳定,但比根本无法使用电力线提示要好:
pip install --user 'git+https://github.com/powerline/powerline.git@develop#powerline'
然后,在您的ipython配置中,将since_5
更改since_7
,如下所示:
from powerline.bindings.ipython.since_7 import PowerlinePrompts
c.TerminalInteractiveShell.simple_prompt = False
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
他们被释放多久?
也许需要一个新版本。
最新版本是2年前。
感谢您发布新版本。 但是,在将电力线升级到2.8-1之后,我仍然遇到此错误。 我不知道为什么。
19:05:12 ~
$ ipython otakutyrant PC
Python 3.8.2 (default, Apr 8 2020, 14:31:25)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.
Traceback (most recent call last):
File "/usr/bin/ipython", line 5, in <module>
start_ipython()
File "/usr/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance
app.start()
File "/usr/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 559, in mainloop
self.interact()
File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 542, in interact
code = self.prompt_for_code()
File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 468, in prompt_for_code
text = self.pt_app.prompt(
File "/usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
return self.app.run(set_exception_handler=set_exception_handler)
File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 811, in run
return loop.run_until_complete(
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 778, in run_async
return await _run_async2()
File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 760, in _run_async2
result = await _run_async()
File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 686, in _run_async
self._redraw()
File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 523, in _redraw
self.context.run(run_in_context)
File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 509, in run_in_context
self.renderer.render(self, self.layout)
File "/usr/lib/python3.8/site-packages/prompt_toolkit/renderer.py", line 581, in render
self.style.invalidation_hash() != self._last_style_hash
File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in invalidation_hash
return tuple(s.invalidation_hash() for s in self.styles)
File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in <genexpr>
return tuple(s.invalidation_hash() for s in self.styles)
File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
return (self.get_style() or self._dummy).invalidation_hash()
File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
return (self.get_style() or self._dummy).invalidation_hash()
File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
return (self.get_style() or self._dummy).invalidation_hash()
File "/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_5.py", line 79, in invalidation_hash
return super(PowerlinePromptStyle, self).invalidation_hash() + 1
TypeError: can only concatenate tuple (not "int") to tuple
If you suspect this is an IPython 7.14.0 bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at [email protected]
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
19:05:15 ✘ ~
$ pacman -Qi powerline otakutyrant PC
Name : powerline
Version : 2.8-1
Description : Statusline plugin for vim, and provides statuslines and prompts for several other applications,
including zsh, bash, tmux, IPython, Awesome, i3 and Qtile
Architecture : x86_64
URL : https://github.com/powerline/powerline
Licenses : MIT
Groups : None
Provides : None
Depends On : python-powerline
Optional Deps : None
Required By : None
Optional For : None
Conflicts With : powerline2 python-powerline<=2.3-1
Replaces : python-powerline<=2.3-1
Installed Size : 28.39 KiB
Packager : Jiachen YANG <[email protected]>
Build Date : Mon 18 May 2020 01:55:40 PM CST
Install Date : Tue 19 May 2020 06:55:56 PM CST
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature
19:09:25 ~
$ otakutyrant PC
/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_7.py
已经存在。
感谢您发布新版本。 但是,在将电力线升级到2.8-1之后,我仍然遇到此错误。 我不知道为什么。
19:05:12 ~ $ ipython otakutyrant PC Python 3.8.2 (default, Apr 8 2020, 14:31:25) Type 'copyright', 'credits' or 'license' for more information IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help. Traceback (most recent call last): File "/usr/bin/ipython", line 5, in <module> start_ipython() File "/usr/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance app.start() File "/usr/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start self.shell.mainloop() File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 559, in mainloop self.interact() File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 542, in interact code = self.prompt_for_code() File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 468, in prompt_for_code text = self.pt_app.prompt( File "/usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt return self.app.run(set_exception_handler=set_exception_handler) File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 811, in run return loop.run_until_complete( File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 778, in run_async return await _run_async2() File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 760, in _run_async2 result = await _run_async() File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 686, in _run_async self._redraw() File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 523, in _redraw self.context.run(run_in_context) File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 509, in run_in_context self.renderer.render(self, self.layout) File "/usr/lib/python3.8/site-packages/prompt_toolkit/renderer.py", line 581, in render self.style.invalidation_hash() != self._last_style_hash File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in invalidation_hash return tuple(s.invalidation_hash() for s in self.styles) File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in <genexpr> return tuple(s.invalidation_hash() for s in self.styles) File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash return (self.get_style() or self._dummy).invalidation_hash() File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash return (self.get_style() or self._dummy).invalidation_hash() File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash return (self.get_style() or self._dummy).invalidation_hash() File "/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_5.py", line 79, in invalidation_hash return super(PowerlinePromptStyle, self).invalidation_hash() + 1 TypeError: can only concatenate tuple (not "int") to tuple If you suspect this is an IPython 7.14.0 bug, please report it at: https://github.com/ipython/ipython/issues or send an email to the mailing list at [email protected] You can print a more detailed traceback right now with "%tb", or use "%debug" to interactively debug it. Extra-detailed tracebacks for bug-reporting purposes can be enabled via: %config Application.verbose_crash=True 19:05:15 ✘ ~ $ pacman -Qi powerline otakutyrant PC Name : powerline Version : 2.8-1 Description : Statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome, i3 and Qtile Architecture : x86_64 URL : https://github.com/powerline/powerline Licenses : MIT Groups : None Provides : None Depends On : python-powerline Optional Deps : None Required By : None Optional For : None Conflicts With : powerline2 python-powerline<=2.3-1 Replaces : python-powerline<=2.3-1 Installed Size : 28.39 KiB Packager : Jiachen YANG <[email protected]> Build Date : Mon 18 May 2020 01:55:40 PM CST Install Date : Tue 19 May 2020 06:55:56 PM CST Install Reason : Explicitly installed Install Script : No Validated By : Signature 19:09:25 ~ $ otakutyrant PC
/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_7.py
已经存在。
您应该添加
from powerline.bindings.ipython.since_7 import PowerlinePrompts
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
配置。 https://github.com/powerline/powerline/blob/develop/docs/source/usage/other.rst
该文档未更新。
我将其添加到配置中,现在可以使用了。 谢谢!
感谢您发布新版本。 但是,在将电力线升级到2.8-1之后,我仍然遇到此错误。 我不知道为什么。
19:05:12 ~ $ ipython otakutyrant PC Python 3.8.2 (default, Apr 8 2020, 14:31:25) Type 'copyright', 'credits' or 'license' for more information IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help. Traceback (most recent call last): File "/usr/bin/ipython", line 5, in <module> start_ipython() File "/usr/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance app.start() File "/usr/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start self.shell.mainloop() File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 559, in mainloop self.interact() File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 542, in interact code = self.prompt_for_code() File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 468, in prompt_for_code text = self.pt_app.prompt( File "/usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt return self.app.run(set_exception_handler=set_exception_handler) File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 811, in run return loop.run_until_complete( File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 778, in run_async return await _run_async2() File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 760, in _run_async2 result = await _run_async() File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 686, in _run_async self._redraw() File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 523, in _redraw self.context.run(run_in_context) File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 509, in run_in_context self.renderer.render(self, self.layout) File "/usr/lib/python3.8/site-packages/prompt_toolkit/renderer.py", line 581, in render self.style.invalidation_hash() != self._last_style_hash File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in invalidation_hash return tuple(s.invalidation_hash() for s in self.styles) File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in <genexpr> return tuple(s.invalidation_hash() for s in self.styles) File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash return (self.get_style() or self._dummy).invalidation_hash() File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash return (self.get_style() or self._dummy).invalidation_hash() File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash return (self.get_style() or self._dummy).invalidation_hash() File "/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_5.py", line 79, in invalidation_hash return super(PowerlinePromptStyle, self).invalidation_hash() + 1 TypeError: can only concatenate tuple (not "int") to tuple If you suspect this is an IPython 7.14.0 bug, please report it at: https://github.com/ipython/ipython/issues or send an email to the mailing list at [email protected] You can print a more detailed traceback right now with "%tb", or use "%debug" to interactively debug it. Extra-detailed tracebacks for bug-reporting purposes can be enabled via: %config Application.verbose_crash=True 19:05:15 ✘ ~ $ pacman -Qi powerline otakutyrant PC Name : powerline Version : 2.8-1 Description : Statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome, i3 and Qtile Architecture : x86_64 URL : https://github.com/powerline/powerline Licenses : MIT Groups : None Provides : None Depends On : python-powerline Optional Deps : None Required By : None Optional For : None Conflicts With : powerline2 python-powerline<=2.3-1 Replaces : python-powerline<=2.3-1 Installed Size : 28.39 KiB Packager : Jiachen YANG <[email protected]> Build Date : Mon 18 May 2020 01:55:40 PM CST Install Date : Tue 19 May 2020 06:55:56 PM CST Install Reason : Explicitly installed Install Script : No Validated By : Signature 19:09:25 ~ $ otakutyrant PC
/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_7.py
已经存在。您应该添加
from powerline.bindings.ipython.since_7 import PowerlinePrompts c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
配置。 https://github.com/powerline/powerline/blob/develop/docs/source/usage/other.rst
该文档未更新。
确实,这些文档已经很老了(最后一个版本是从1.5年前开始的)。 但是,自动构建无法正常工作,我缺乏检查/更改有关配置的权限,对不起。
@ PH111P请将新版本也推送到PyPI。 它仍然只有2.7版本...
可悲的是,我认为我没有访问权限。
同时,您可以尝试pip install git+https://github.com/powerline/powerline.git@develop
。
最有用的评论
在发布更改之前,请先检出
develop
分支以获取更改。 它可能不如master
稳定,但比根本无法使用电力线提示要好:然后,在您的ipython配置中,将
since_5
更改since_7
,如下所示: