How to get autocomplete in jupyter notebook without using tab?
Matthew Barrera
I would like to get an autocompletion feature in notebooks i.e. when I type something, a dropdown menu appears, with all the possible things I might type, without having to press the tab button. Is there such a thing?
I tried :
%config IPCompleter.greedy=True
but this requires the tab button to be pressed
7 Answers
There is an extension called Hinterland for jupyter, which automatically displays the drop down menu when typing. There are also some other useful extensions.
In order to install extensions, you can follow the guide on this github repo. To easily activate extensions, you may want to use the extensions configurator.
5The auto-completion with Jupyter Notebook is so weak, even with hinterland extension. Thanks for the idea of deep-learning-based code auto-completion. I developed a Jupyter Notebook Extension based on TabNine which provides code auto-completion based on Deep Learning. Here's the Github link of my work: jupyter-tabnine.
It's available on pypi index now. Simply issue following commands, then enjoy it:)
pip3 install jupyter-tabnine
jupyter nbextension install --py jupyter_tabnine
jupyter nbextension enable --py jupyter_tabnine
jupyter serverextension enable --py jupyter_tabnineI would suggest hinterland extension.
In other answers I couldn't find the method for how to install it from pip, so this is how you install it.
First, install jupyter contrib nbextensions by running
pip install jupyter_contrib_nbextensions
Next install js and css file for jupyter by running
jupyter contrib nbextension install --user
and at the end run,
jupyter nbextension enable hinterland/hinterland
The output of last command will be
Enabling notebook extension hinterland/hinterland... - Validating: OK As mentioned by @physicsGuy above, You can use the hinterland extension. Simple steps to do it.
Installing nbextension using conda forge channel. Simply run the below command in conda terminal:
conda install -c conda-forge jupyter_nbextensions_configuratorNext Step enabling the hinterland extension. Run the below command in conda terminal:
jupyter nbextension enable hinterland/hinterlandThat's it, done.
2I am using Jupiter Notebook 5.6.0. Here, to get autosuggestion I am just hitting Tab key after entering at least one character.
**Example:** Enter character `p` and hit Tab.To get the methods and properties inside the imported library use same Tab key with Alice
import numpy as np np. --> Hit Tab key Without doing this %config IPCompleter.greedy=True after you import a package like numpy or pandas in this way;import numpy as npimport pandas as pd.
Then you type in pd. then tap the tab button it brings out all the possible methods to use very easy and straight forward.
Add the below to your keyboard user preferences on jupyter lab (Settings->Advanced system editor)
{ "shortcuts":[ { "command": "completer:invoke-file", "keys": [ "Ctrl Space" ], "selector": ".jp-FileEditor .jp-mod-completer-enabled" }, { "command": "completer:invoke-file", "keys": [ "Ctrl Space" ], "selector": ".jp-FileEditor .jp-mod-completer-enabled" }, { "command": "completer:invoke-notebook", "keys": [ "Ctrl Space" ], "selector": ".jp-Notebook.jp-mod-editMode .jp-mod-completer-enabled" } ]
} 1