Jupyter auto-completion/suggestions on tab not working

Viewed 1136

While working with libraries like nltk the tab auto-complete was like a blessing which would comfortably list the functions and attributes of the module in use. It used to work fine few months back but recently I have been facing this new issue of the auto-completes not appearing. They seem to work fine initially but after some time the kernel activity indicator just blinks on pressing tab and nothing happens. On the jupyter server side, the following message appears:

[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__'".

While this is not something that would seriously hamper the development process but it would be really helpful if it works properly.

I am currently using python 3.8.6 64-bit (Was facing the same issue on older versions as well) and running the notebook in Microsoft Edge Chromium

1 Answers

Jedi is the problem here.

You can solve this problem through jupyter magic. Just add the following at the top of your notebook:

%config Completer.use_jedi = False

Another way of handling this is removing the jedi cache on your system (https://github.com/ipython/ipython/issues/12134#issuecomment-590952054):

You need to purge the jedi cache: just delete the folder (linux)

~/.cache/jedi/

and you should be fine.

For other OS, please check

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

Related