python - 选项卡上的 Jupyter 自动完成/建议不起作用

标签 python python-3.x jupyter-notebook ipython

在使用像 nltk 这样的库时,选项卡自动完成就像一种祝福,它可以轻松地列出正在使用的模块的功能和属性。几个月前它曾经工作得很好,但最近我一直面临这个自动完成没有出现的新问题。它们最初似乎工作正常,但一段时间后,内核事件指示器只是在按 Tab 键时闪烁,而没有任何 react 。在 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__'".
虽然这不会严重阻碍开发过程,但如果它工作正常,它会非常有帮助。
我目前正在使用 python 3.8.6 64 位(在旧版本上也面临同样的问题)并在 Microsoft Edge Chromium 中运行笔记本

最佳答案

绝地是这里的问题。
你可以通过 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

关于python - 选项卡上的 Jupyter 自动完成/建议不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64178482/

相关文章:

python - 如何用 Python 打开 bash session 并保持通信?

python - 无法在同一文件夹中导入模块

python - 如何将 jupyter notebook 目录中的模块导入到较低目录的 notebook 中?

python - Datalab 到 BigQuery - 将变量值插入 SQL 中

python - 如何在 jupyter notebook 5 中逐行分析 python 3.5 代码

python数组包含切片索引

python - django.db.utils.IntegrityError : duplicate key value violates unique constraint "spirit_category_category_pkey" 错误

Python-满足不同条件时如何从变量中选择

Python3 导入错误 : No module named '_tkinter'

python - "OSError: [Errno 22] Invalid argument"当读取大文件时