6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Jupyterでタブ補完が効かない時

Posted at

困る

Jupyterを使っていて、タブを打っても補完候補が表示されなくなる時がある。何かしらのパッケージをアップデートした後など。

原因と対処法を、ここへ追記していく。

JediとIPythonのバージョン相性問題

(2021年3月3日)

Jupyterのエラーメッセージ

JupyterLabのログをとっているが、そこに以下のようなエラーメッセージが出ていた。

[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 265, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/tornado/gen.py", line 762, in run
    value = future.result()
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/tornado/gen.py", line 234, in wrapper
    yielded = ctx_run(next, result)
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 580, in complete_request
    matches = yield gen.maybe_future(self.do_complete(code, cursor_pos))
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 356, in do_complete
    return self._experimental_do_complete(code, cursor_pos)
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 381, in _experimental_do_complete
    completions = list(_rectify_completions(code, raw_completions))
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/IPython/core/completer.py", line 484, in rectify_completions
    completions = list(completions)
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/IPython/core/completer.py", line 1818, in completions
    for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/IPython/core/completer.py", line 1861, in _completions
    matched_text, matches, matches_origin, jedi_matches = self._complete(
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/IPython/core/completer.py", line 2029, in _complete
    completions = self._jedi_matches(
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/IPython/core/completer.py", line 1373, in _jedi_matches
    interpreter = jedi.Interpreter(
  File "/home/kttn/anaconda3/envs/dl/lib/python3.8/site-packages/jedi/api/__init__.py", line 725, in __init__
    super().__init__(code, environment=environment,
TypeError: __init__() got an unexpected keyword argument 'column'

原因

自動補完処理を担当しているJediパッケージと、JupyterのバックエンドになっているIPythonのバージョンの相性が悪い。

上記記事の解決策コメントは2021年1月23日時点のもので、Jediのv0.18とIPythonの7.19が相容れないことを指摘している。

実際私の環境はまさにそうなっていた。

> conda list | grep jedi
jedi                      0.18.0           py38h578d9bd_2    conda-forge

> conda list | grep ipython
ipython                   7.19.0           py38h81c977d_0    conda-forge
ipython-genutils          0.2.0                    pypi_0    pypi
ipython_genutils          0.2.0                      py_1    conda-forge

対処

IPythonかJediのバージョンを変える。

私の場合はJediのバージョンを落とした。

> conda install jedi=0.17.2 -c conda-forge

補完が効かないノートブックのカーネルを再起動すると、補完が効くようになっていた。

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?