Notebook: TAB completion does not work in Jupyter Notebook while another cell is running

Created on 14 Jul 2018  路  14Comments  路  Source: jupyter/notebook

Normally, TAB completion works fine in jupyter notebook.

However, if there is another cell running (e.g. a long running sub-process) TAB doesn't do anything until that and any other queued for execution cells won't finish their course. It does function in other notebooks, but not in other cells of the same notebook that's "busy".

To reproduce, run this cell:

import time
time.sleep(30)

then start a new cell, and try to autocomplete (while):

whil

No completion happens.

This behavior slows down the development process, and in a way somewhat defeats the idea of separate cells. As one can type code, but can't do it efficiently.

Thank you.

jupyter-1.0.0, python-3.6.6 here.

Most helpful comment

I have an issue where tab completion doesn't work full stop. I've checked that all cells above have been run, so it should tab complete.

In a cell:
import pandas as pd

Separate cell:
pd.DataFrame

In theory, you should be able to type pd.Da + [tab] but nothing. Anyone else had a similar issue?
This goes for all other methods and attributes as well. pd.DataFrame was just an example.

I found a solution here:
Quoting Ramon Martinez:
"The issue can be solved by using the following magic which deactivates jedi
%config Completer.use_jedi = False"
This worked for me.
As pointed in one comment, it seems to be a very recent issue, but I don't know what's the scenario to reproduce it.
I just updated Anaconda to 1.10.0 and I have faced this problem in both Jupyter and Jupyter Lab (6.1.5 and 2.2.6, respectively) on Windows 10 Home Version 10.0.19041 Compilation19041.

All 14 comments

It's expected, although we know it's not ideal. Tab completion works by sending a message to the kernel asking for a list of completions. If the kernel is busy doing something else at the time, it doesn't reply.

Thank you for confirming the current state of things, Thomas.

Are you also saying that the design can't be changed to support a working TAB completion regardless of the state of the kernel? e.g. having a dedicated thread listening to typing activity, while having another thread doing the executions?

Thank you.

Completing from a secondary thread causes problems for some libraries that aren't expecting it - the IPython terminal interface does this at the moment, and we've had several bug reports about it. There's no easy way to fix this without redesigning how Jupyter works (edit: as far as I know).

Thank you for explaining the reason for this limitation, Thomas.

Talking about redesign, do you by chance know whether jupyterlab has this limitation resolved or is planning to?

I don't think so; it's a limitation around the way kernels work, and Jupyterlab doesn't change that.

You can get round it to a degree by doing some completion in the frontend. The notebook already has some simple frontend completion based on words you've used before in the notebook (or cell? I forget). It's tricky to do more without embedding a lot of knowledge about the kernel language, though.

In which can this be added to the feature-request list?

i.e. avail partial TAB completion functionality based on local words when the kernel is busy

Thank you!

Same

Is there a work around?

Thanks

Did you try Help-Keyboard Shortcuts, and editing automatically indent selection or auto indent? I had the same problem and just solved it.

I am having a hard time understanding the relevance of your suggestion, @HakanKiymaz - what does it have to do with indent? Which problem did you solve?

Best fix for this is using Anaconda or what ever IDE is to create a new environment. I know its a hassle to reinstall your libraries but the new environment will work with tabbing to autocomplete

My hunch is that you're referring to a different issue. I'm not sure how a different environment can make any difference if there was no change in the core of the software. Unless there was one, then please kindly indicate the change that affects this issue. Thank you.

I have an issue where tab completion doesn't work full stop. I've checked that all cells above have been run, so it should tab complete.

In a cell:
import pandas as pd

Separate cell:
pd.DataFrame

In theory, you should be able to type pd.Da + [tab] but nothing. Anyone else had a similar issue?
This goes for all other methods and attributes as well. pd.DataFrame was just an example.

I have an issue where tab completion doesn't work full stop. I've checked that all cells above have been run, so it should tab complete.

In a cell:
import pandas as pd

Separate cell:
pd.DataFrame

In theory, you should be able to type pd.Da + [tab] but nothing. Anyone else had a similar issue?
This goes for all other methods and attributes as well. pd.DataFrame was just an example.

I found a solution here:
Quoting Ramon Martinez:
"The issue can be solved by using the following magic which deactivates jedi
%config Completer.use_jedi = False"
This worked for me.
As pointed in one comment, it seems to be a very recent issue, but I don't know what's the scenario to reproduce it.
I just updated Anaconda to 1.10.0 and I have faced this problem in both Jupyter and Jupyter Lab (6.1.5 and 2.2.6, respectively) on Windows 10 Home Version 10.0.19041 Compilation19041.

Was this page helpful?
0 / 5 - 0 ratings