34

I'm using jupyter notebook, and it works fine, but when I press TAB, the auto-completion doesn't work. I already checked all the similar cases in StackOverflow, but none of the solutions worked for me. I have also tried to do "pip upgrade" to: IPython, IPYKernel, Jedi, and Tornado, the upgrade works fine but the problem is still there. I tried in Firefox, Chrome and Edge. When I press TAB I can see those errors in the terminal:

[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\ipykernel\kernelbase.py", line 265, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\tornado\gen.py", line 762, in run
    value = future.result()
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\tornado\gen.py", line 234, in wrapper
    yielded = ctx_run(next, result)
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\ipykernel\kernelbase.py", line 580, in complete_request
    matches = yield gen.maybe_future(self.do_complete(code, cursor_pos))
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\ipykernel\ipkernel.py", line 356, in do_complete
    return self._experimental_do_complete(code, cursor_pos)
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\ipykernel\ipkernel.py", line 381, in _experimental_do_complete
    completions = list(_rectify_completions(code, raw_completions))
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\IPython\core\completer.py", line 484, in rectify_completions
    completions = list(completions)
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\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 "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\IPython\core\completer.py", line 1861, in _completions
    matched_text, matches, matches_origin, jedi_matches = self._complete(
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\IPython\core\completer.py", line 2029, in _complete
    completions = self._jedi_matches(
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\IPython\core\completer.py", line 1373, in _jedi_matches
    interpreter = jedi.Interpreter(
  File "c:\users\tomer\appdata\local\programs\python\python39\lib\site-packages\jedi\api\__init__.py", line 725, in __init__
    super().__init__(code, environment=environment,
TypeError: __init__() got an unexpected keyword argument 'column'

I'll be glad if someone can help me with this case

krassowski
  • 13,598
  • 4
  • 60
  • 92
Tomer
  • 353
  • 1
  • 3
  • 5
  • 1
    Possible duplicate of [readline - TAB completion does not work in Jupyter Notebook but fine in iPython terminal - Stack Overflow](https://stackoverflow.com/questions/33665039/tab-completion-does-not-work-in-jupyter-notebook-but-fine-in-ipython-terminal) . – user202729 Feb 03 '21 at 14:23
  • 1
    No, this is not a duplicate of the question you link because that question is about completion working in IPython but not in notebook. The latest upgrade to jedi broke completion in all of IPython and answers to a 5-years old question about a different issue are misleading here. – krassowski Feb 10 '21 at 13:19

4 Answers4

57

The solution from @techno1731 is sub-optimal because it just disables jedi rather than fixing the underlying issue.

The latest jedi (0.18) release is incompatible with IPython 7.19 see this discussion. IPython: 7.20 (released Feb 1st 2020) and 8.0 (not yet released) have a compatibility fix.

The correct workaround at this time is to upgrade IPython:

pip install -U "ipython>=7.20"

In future you can search for the final two lines of the trackback after removing all path fragments specific to your installation, this is searching for:

     super().__init__(code, environment=environment,
TypeError: __init__() got an unexpected keyword argument 'column'

This will give you the relevant issues on GitHub in the first two Google result as for today.

Note: this is a copy of my answer from Giant IPKernelApp Error Using Hydrogen in Atom question which indeed can appear unrelated given the Hydrogen/Atom setting. I will now vote to close all other questions on the topic as duplicate of this one.

krassowski
  • 13,598
  • 4
  • 60
  • 92
  • 2
    Got the same error with jedi 0.18.0 and ipython 7.26.0. Downgrading to jedi 0.17.2 as suggested in https://stackoverflow.com/a/65513532/1333610 worked. – arun Aug 10 '21 at 17:20
  • If you get this error with newer IPython (which would be very strange), you should fill in a bug report rather than downgrading and hoping someone else will do it. Silently downgrading open-source projects is a disservicve to everyone (community as they cannot solve issues they don't know about, and yourself as you expose your system to security issues which were patched in newer releases). – krassowski Oct 19 '21 at 08:23
  • @krassowski maybe. but in the meantime, this works. – eric Feb 24 '22 at 16:21
20

I encontered the same issue some time ago with Jupyterlab when working locally on my machine with virtual environments.

This is a problem with Jedi being too slow (or rather taking forever) to load the completion, what worked for me was to add the follwing line at the top of the notebook (for example where you typically do the imports):

# Jedi not working
%config Completer.use_jedi = False

This should do the trick.

user202729
  • 3,358
  • 3
  • 25
  • 36
techno1731
  • 309
  • 1
  • 4
  • 1
    This works in jupyter notebook too. [Official documentation](https://ipython.readthedocs.io/en/stable/config/options/terminal.html?highlight=use_jedi#configtrait-Completer.use_jedi) (also include the info how to make it permanent). See also https://stackoverflow.com/questions/65321798/how-to-config-completer-use-jedi-to-false-in-juypter-notebook-permanently – user202729 Feb 03 '21 at 14:19
6

I'm using a previous version of jedi instead:

pip install jedi==0.17

that works for me.

d1sh4
  • 1,710
  • 5
  • 21
Xiaobai
  • 61
  • 1
  • 2
0

Uninstall your jupyter completely in your environment. Then, use conda to install jupyter notebook, and let conda to resolve the dependency for you.

Step 1 : Uninstall jupyter completely.

python3 -m pip uninstall -y jupyter jupyter_core jupyter-client jupyter-console jupyterlab_pygments notebook qtconsole nbconvert nbformat

Step 2: Install jupyter notebook using conda.

conda install -c conda-forge notebook 
conda install -c conda-forge nb_conda_kernels

Relaunch your notebook.

Wong Tat Yau
  • 953
  • 11
  • 11