jupyter notebook tab 报错 无法自动提示 - xd21303/Notebook GitHub Wiki
jupyter notebook 按tab无法自动提示,命令行里报错,报错内容:
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/cache.py", line 109, in wrapper
return dct[key]
KeyError: ((), frozenset())
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/tornado/gen.py", line 762, in run
value = future.result()
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/tornado/gen.py", line 234, in wrapper
yielded = ctx_run(next, result)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 583, in complete_request
matches = yield gen.maybe_future(self.do_complete(code, cursor_pos))
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 360, in do_complete
return self._experimental_do_complete(code, cursor_pos)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 385, in _experimental_do_complete
completions = list(_rectify_completions(code, raw_completions))
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/IPython/core/completer.py", line 492, in rectify_completions
completions = list(completions)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/IPython/core/completer.py", line 1837, in completions
for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/IPython/core/completer.py", line 1894, in _completions
signature = _make_signature(jm)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/IPython/core/completer.py", line 1001, in _make_signature
signatures = completion.get_signatures()
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/api/classes.py", line 572, in get_signatures
for s in self._get_signatures()
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/api/classes.py", line 561, in _get_signatures
return [sig for name in names for sig in name.infer().get_signatures()]
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/api/classes.py", line 561, in <listcomp>
return [sig for name in names for sig in name.infer().get_signatures()]
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/cache.py", line 111, in wrapper
result = method(self, *args, **kwargs)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/inference/compiled/mixed.py", line 129, in infer
return _create(self._inference_state, compiled_value, module_context)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/inference/cache.py", line 43, in wrapper
rv = function(obj, *args, **kwargs)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/inference/compiled/mixed.py", line 257, in _create
result = _find_syntax_node_name(inference_state, python_object)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/inference/compiled/mixed.py", line 237, in _find_syntax_node_name
code_lines = get_cached_code_lines(inference_state.grammar, path)
File "/opt/anaconda3/envs/py38/lib/python3.8/site-packages/jedi/parser_utils.py", line 280, in get_cached_code_lines
return parser_cache[grammar._hashed][path].lines
KeyError: '/opt/anaconda3/envs/py38/lib/python3.8/site-packages/IPython/core/interactiveshell.py'
出现问题的版本号
jedi 0.17.0
notebook 6.3.0
ipykernel 5.3.4
ipython 7.22.0
原因,notebook使用了jedi,jedi的bug。
修复方法:
%config IPCompleter.use_jedi = False
%config Completer.use_jedi = False
生成ipython的配置文件
ipython profile create
找到并修改以下配置并保存
c.IPCompleter.use_jedi = False
c.Completer.use_jedi = False