Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Completion in IPython (jupyter) does now work (unexpected keyword argument 'column')

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

like image 231
Tomer Avatar asked Jan 22 '21 10:01

Tomer


People also ask

How do I enable code completion in Jupyter?

To enable code autocomplete in Jupyter Notebook or JupyterLab, you just need to hit the Tab key while writing code. Jupyter will suggest a few completion options. Navigate to the one you want with the arrow keys, and hit Enter to choose the suggestion.

Do IPython has tab completion feature?

Latex and Unicode completion IPython and compatible frontends not only can complete your code, but can help you to input a wide range of characters. In particular we allow you to insert a unicode character using the tab completion mechanism.

Why is my Jupyter Notebook not working?

Jupyter doesn't load or doesn't work in the browser Try disabling any browser extensions and/or any Jupyter extensions you have installed. Some internet security software can interfere with Jupyter. If you have security software, try turning it off temporarily, and look in the settings for a more long-term solution.

Does JupyterLab have autocomplete?

Yes you have auto-complete built-in Jupyter, like you have in any other Jupyter environment. Simply hit the "Tab" key while writing code. This will open a menu with suggestions. Hit "Enter" to choose the suggestion.


3 Answers

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.

like image 149
krassowski Avatar answered Oct 24 '22 03:10

krassowski


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.

like image 40
techno1731 Avatar answered Oct 24 '22 01:10

techno1731


I'm using a previous version of jedi instead:

pip install jedi==0.17

that works for me.

like image 37
Xiaobai Avatar answered Oct 24 '22 01:10

Xiaobai