Jupyter自动完成/关于选项卡不工作的建议

2024-06-16 11:26:50 发布

您现在位置:Python中文网/ 问答频道 /正文

使用nltk之类的库时,“自动完成”选项卡就像是一件好事,它可以轻松地列出正在使用的模块的函数和属性。几个月前它还可以正常工作,但最近我遇到了一个新问题:自动完成并没有出现。它们一开始似乎工作正常,但一段时间后,内核活动指示器在按下tab键时闪烁,什么也没有发生。在jupyter服务器端,将显示以下消息:

[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "<the path>\venv\lib\site-packages\ipykernel\kernelbase.py", line 268, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "<the path>\venv\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "<the path>\venv\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "<the path>\venv\lib\site-packages\ipykernel\kernelbase.py", line 583, in complete_request
    matches = yield gen.maybe_future(self.do_complete(code, cursor_pos))
  File "<the path>\venv\lib\site-packages\ipykernel\ipkernel.py", line 360, in do_complete
    return self._experimental_do_complete(code, cursor_pos)
  File "<the path>\venv\lib\site-packages\ipykernel\ipkernel.py", line 385, in _experimental_do_complete
    completions = list(_rectify_completions(code, raw_completions))
  File "<the path>\venv\lib\site-packages\IPython\core\completer.py", line 484, in rectify_completions
    completions = list(completions)
  File "<the path>\venv\lib\site-packages\IPython\core\completer.py", line 1819, in completions
    if c and (c in seen):
  File "<the path>\venv\lib\site-packages\IPython\core\completer.py", line 1876, in _completions
    else:
  File "<the path>\venv\lib\site-packages\IPython\core\completer.py", line 991, in _make_signature
    return '(%s)'% ', '.join([f for f in (_formatparamchildren(p) for p in completion.params) if f])
  File "<the path>\venv\lib\site-packages\IPython\core\completer.py", line 991, in <listcomp>
    return '(%s)'% ', '.join([f for f in (_formatparamchildren(p) for p in completion.params) if f])
  File "<the path>\venv\lib\site-packages\IPython\core\completer.py", line 991, in <genexpr>
    return '(%s)'% ', '.join([f for f in (_formatparamchildren(p) for p in completion.params) if f])
  File "<the path>\venv\lib\site-packages\IPython\core\completer.py", line 968, in _formatparamchildren
    raise ValueError('Jedi function parameter description have change format.'
ValueError: Jedi function parameter description have change format.Expected "param ...", found 'def __subclasshook__'".

虽然这不会严重阻碍开发过程,但如果它工作正常,它将非常有用

我目前正在使用Python3.8.6 64位(在旧版本中也面临同样的问题),并在Microsoft Edge Chromium中运行笔记本


Tags: thepathinpycoreforvenvlib
1条回答
网友
1楼 · 发布于 2024-06-16 11:26:50

绝地是这里的问题

你可以通过jupyter魔法解决这个问题。只需在笔记本顶部添加以下内容:

%config Completer.use_jedi = False

另一种处理方法是删除系统(https://github.com/ipython/ipython/issues/12134#issuecomment-590952054)上的绝地缓存:

你需要清除绝地缓存:只需删除文件夹(linux)

~/.cache/jedi/

你应该没事的

对于其他操作系统,请检查

https://jedi.readthedocs.io/en/latest/docs/settings.html#filesystem-cache

相关问题 更多 >