Ipython: 崩溃错误

创建于 2021-01-20  ·  4评论  ·  资料来源: ipython/ipython

[3] 中:nn.relu
回溯(最近一次通话最后):
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/ptutils.py”,第 113 行,在 get_completions
从 self._get_completions(body, offset, cursor_position, self.ipy_completer) 产生
_get_completions 中的文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/ptutils.py”,第 129 行
对于 c 完成:
_deduplicate_completions 中的文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py”,第 438 行
完成 = 列表(完成)
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py”,第 1818 行,完成
对于 c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
_completions 中的文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py”,第 1862 行
full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column)
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py”,第 2030 行,在 _complete
cursor_pos, cursor_line, full_text)
_jedi_matches 中的文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/core/completer.py”,第 1374 行
text[:offset], 命名空间, column=cursor_column, line=cursor_line + 1)
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/jedi/api/__init__.py”,第 726 行,在 __init__
项目=项目(Path.cwd()), **kwds)
TypeError: __init__() 得到了一个意外的关键字参数“列”

在处理上述异常的过程中,又出现了一个异常:

回溯(最近一次通话最后):
文件“/home/hcl/miniconda3/envs/pytorch/bin/ipython”,第 8 行,在
sys.exit(start_ipython())
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/__init__.py”,第 126 行,在 start_ipython
返回 launch_new_instance(argv=argv, *kwargs)文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/traitlets/config/application.py”,第 845 行,在 launch_instanceapp.start()文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/ipapp.py”,第 356 行,开始self.shell.mainloop()文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py”,第 564 行,在 mainloopself.interact()交互中的文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py”,第 547 行代码 = self.prompt_for_code()prompt_for_code 中的文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py”,第 475 行* self._extra_prompt_options())
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py”,第 1013 行,提示符
返回 self.app.run(set_exception_handler=set_exception_handler)
运行中的文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/application/application.py”,第 817 行
self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/asyncio/base_events.py”,第 584 行,在 run_until_complete
返回future.result()
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/application/application.py”,第 783 行,在 run_async
返回等待_run_async2()
_run_async2 中的文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/application/application.py”,第 771 行
等待 self.cancel_and_wait_for_background_tasks()
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/application/application.py”,第 872 行,在 cancel_and_wait_for_background_tasks
等待任务
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/buffer.py”,第 1854 行,在 new_coroutine
等待协程( a, * kw)
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/buffer.py”,第 1684 行,在 async_completer
文档,完成事件
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/completion/base.py”,第 270 行,在 get_completions_async
文档,完成事件
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/prompt_toolkit/completion/base.py”,第 196 行,在 get_completions_async
对于 self.get_completions(document, complete_event) 中的项目:
文件“/home/hcl/miniconda3/envs/pytorch/lib/python3.7/site-packages/IPython/terminal/ptutils.py”,第 116 行,在 get_completions
exc_type, exc_value, exc_tb = sys.exc_info()
NameError:名称“sys”未定义

如果您怀疑这是 IPython 7.19.0 错误,请在以下位置报告:
https://github.com/ipython/ipython/issues
或发送电子邮件至[email protected]的邮件列表

您现在可以使用“%tb”打印更详细的回溯,或使用“%debug”
以交互方式调试它。

可以通过以下方式启用用于错误报告目的的超详细回溯:
%config Application.verbose_crash=True

最有用的评论

读取回溯:

  1. systraceback导入在IPython/terminal/ptutils.py中丢失,这是导致 Ipython 崩溃的问题;
  2. jedi/api/__init__.py中,它抱怨“列”参数被传递给Script.__init__ ,它不接受这样的参数;
  3. 这个错误来自IPython/core/completer.py ,在第 1373 行创建了一个新的jedi.Interpreter ,向它传递了一个“column”参数,它阻塞了它。

创建Script对象的方式在 jedi 0.17 和 jedi 0.18 之间发生了变化:
在 0.17 中:

     def __init__(self, code=None, line=None, column=None, path=None,                                    
                 encoding=None, sys_path=None, environment=None,                                               
                 project=None, source=None):

在 0.18 中:

    def __init__(self, code=None, *, path=None, environment=None, project=None):

如果您安装 jedi 0.17 而不是 jedi 0.18,则当前版本的 ipython 应该可以工作。
这对我有用:

pip uninstall jedi
pip install jedi==0.17.2

所有4条评论

这个问题的根源不是 ipython。 实际上来自jedi包。 但 ipython 也有与此相关的错误。 sys模块未在get_completions异常中导入。

systraceback模块在 7 个月前添加,但未在 pypi 中更新。 因此,此错误与 ipython 无关。 jedi中的错误。

您能否提供一些更详细的信息,说明为什么这是jedi中的问题?
PyPI 上最新的ipython版本是 7.19.0,其中包含缺失的导入 - 正如您已经注意到的 - 在 master 上修复但未发布。
https://github.com/ipython/ipython/blob/7.19.0/IPython/terminal/ptutils.py

不导入sys
https://github.com/ipython/ipython/blob/223e783c447a773a497809646ca0d874ea10ceeb/IPython/terminal/ptutils.py#L20 -L24

sys的用法
https://github.com/ipython/ipython/blob/223e783c447a773a497809646ca0d874ea10ceeb/IPython/terminal/ptutils.py#L116

读取回溯:

  1. systraceback导入在IPython/terminal/ptutils.py中丢失,这是导致 Ipython 崩溃的问题;
  2. jedi/api/__init__.py中,它抱怨“列”参数被传递给Script.__init__ ,它不接受这样的参数;
  3. 这个错误来自IPython/core/completer.py ,在第 1373 行创建了一个新的jedi.Interpreter ,向它传递了一个“column”参数,它阻塞了它。

创建Script对象的方式在 jedi 0.17 和 jedi 0.18 之间发生了变化:
在 0.17 中:

     def __init__(self, code=None, line=None, column=None, path=None,                                    
                 encoding=None, sys_path=None, environment=None,                                               
                 project=None, source=None):

在 0.18 中:

    def __init__(self, code=None, *, path=None, environment=None, project=None):

如果您安装 jedi 0.17 而不是 jedi 0.18,则当前版本的 ipython 应该可以工作。
这对我有用:

pip uninstall jedi
pip install jedi==0.17.2
此页面是否有帮助?
0 / 5 - 0 等级