60

As someone trying to learn the ins and outs of Python (with emphasis on scientific computing - ie: pandas, numpy, scikit-learn), most of the gurus out there seem to recommend and use iPython notebooks. My biggest sticking point as a beginner/intermediate coder is that I NEED code completion / intellisense -like functionality from an IDE to learn the function parameters. I'm not hard-wired yet to just know what parameters are available at my current development.

In iPython, I noticed I can press Tab to show the drop-down of options (seen below as pd.) but I don't want to have to hit each time. That's not user-friendly for my needs. Instead, I would like it to show only available classes and methods when I press dot.

Secondly, I notice that if I did say pd.read_csv(<TAB>, I get a lot more options than are the actual parameters in read_csv.

Question: Can iPython automatically show accurate code completion options instantly after pressing dot / period? Also, is there a way to configure it to only show the available function parameters when within a function?

To make this question super-specific, I'm not asking about using any other IDE; I'm asking very specifically in regards to just iPython and wondering if there's a way to set some kind of configuration to achieve accurate "dot" display options instantly when pressing "dot" (no time delay).

enter image description here

Example below shows Desktop which is obviously not a parameter of pd.read_csv().

enter image description here

2
  • Just mentioning a solution for full IntelliSense for JupyterLab I am working on: github.com/krassowski/jupyterlab-lsp (including completion on dot and signature suggestion). Not sure if this would qualify as an answer... - should I post one?
    – krassowski
    Commented Sep 8, 2019 at 15:05
  • @krassowski looks like a potential answer to this question. auto invocation on '.' (dot) is the primary pain-point and purpose of this question. If you think your library is a solution, by all means feel free to contribute an answer in the context of this question.
    – Jarad
    Commented Sep 8, 2019 at 17:24

7 Answers 7

62

You can press <Shift>-<Tab> to get a tooltip showing the function's signature:

enter image description here

Alternatively, invoking zip? opens a documentation pane at the bottom of the window.

As far as having the tooltip open automatically, I'm unsure. I'd guess that it isn't possible via configuration.

5
  • 2
    Neither shortcut displays any hint for class members, functions parameters or anything. Is there anything else I've should install to enable?
    – tutuca
    Commented Apr 20, 2016 at 1:16
  • 1
    @tutuca As far as I am aware, this should work without needing any packages other than jupyter. I'd suggest making sure that you have a recent version of jupyter installed, and perhaps looking to see if the shortcut is different on your operating system.
    – jme
    Commented Apr 21, 2016 at 19:20
  • You are right, my libraries wasn't reloading, I just turned the notebook on and off and it started working. Thanks for replying :)
    – tutuca
    Commented Apr 21, 2016 at 20:25
  • Is there a way to access this feature in the interactive IPython shell?
    – airdas
    Commented Feb 3, 2017 at 11:09
  • I have to write the complete function name to see its description. It doesn't show the list of functions to choose from.
    – Shashwat
    Commented Nov 6, 2019 at 11:38
44

Almost 3 years later, I've finally come across a potential solution.

Answer: Install nbextensions and enable the Hinterland extension.

Enable code autocompletion menu for every keypress in a code cell, instead of only calling it with tab.

Here's what you do:

  1. pip install jupyter_contrib_nbextensions
  2. jupyter contrib nbextension install --user
  3. Start jupyter notebook (browser launches)
  4. One of the tabs should now show "Nbextensions"
  5. There, you will find "Hinterland". Check the box to enable.

Hinterland has some adjustable options like:

  • hinterland.hint_delay: delay in milliseconds between keypress & hint request.
  • hinterland.enable_at_start: Whether to enable hinterland's continuous hinting when notebook is first opened, or if false, only when selected from the help-menu item.
  • hinterland.hint_inside_comments: Whether to request hints while typing code comments. Defaults to false.
  • Other regex options: hinterland.exclude_regexp, hinterland.include_regexp, hinterland.tooltip_regexp

enter image description here

3
  • 1
    Thanks for the answer, just solved my problem! Commented Mar 6, 2021 at 2:23
  • How to turn off auto completion in it?
    – Vivek
    Commented Aug 20, 2021 at 16:38
  • If you are in a conda environment install it like this instead conda install -c conda-forge jupyter_contrib_nbextensions Commented Nov 3, 2021 at 20:54
8

Now there's a better way to get accurate code completion operation. It can be triggered by any character you typed. Inspired by TabNine, I developed a code auto-completion extension for Jupyter Notebook 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_tabnine

demo

1
7

This is what worked for me:

pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter notebook

To see the Nbextensions tab if something has hidden it:

jupyter nbextensions_configurator enable --user
  • under Nbextensions uncheck "disable confirguration for nbextensions without explicit compatibility ..." (disclaimer - all risks are yours for doing this)
  • select only
    • "Hinterland" for the formatting ones. I had some other nbextensions selected and somehow it was not working.
    • "Nbextension edit menu item" & "Nbestenision dashboard tab" (in order to see this tab again next time)

enter image description here

6

If you are using Jupyter notebook and your Intellisense is not working then type below and give a press TAB after (.)

%config IPCompleter.greedy=True

it will work for you as well.

2
  • 3
    It's hard for me to tell if this answers their question or just suggests pressing tab after the . (which is explicitly what the user wishes to avoid in their question).
    – ti7
    Commented Jul 30, 2018 at 18:25
  • as of now we don't have anything that can avoid pressing Tab. May be in future... Commented Aug 1, 2018 at 19:35
4

If you are using JupyterLab, the jupyterlab-lsp extension (with pyls server installed) does invoke the completer automatically upon typing the dot (or any character if told so):

enter image description here

Pros:

  • completion suggestions are available even before the code gets executed (static analysis)
  • documentation panel can be displayed for the completion candidates
  • type icons (with different themes available)
  • other IDE features included (signature hints, diagnostics, rename, etc)

Cons:

  • not yet as configurable as Hinterland (but it is getting there)
  • some users prefer to only get completions for objects in already executed cells

Assuming Python 3.6+ and JupyterLab 3.0+ are already installed:

pip install jupyterlab-lsp    # client and server extension
pip install jedi-language-server     # fast language server, or
# pip install python-language-server[all]     # another language server

For more detailed and up-to-date installation instructions please see this link.

Disclaimer: I am one of the authors of this extension.

1
  • 1
    For those like me stuck on python3.6, the highest supported versions of the libraries above are: python -m pip install jedi-language-server==0.21.0 jedi==0.17.2 ipython==7.16.1
    – Meitham
    Commented Aug 24, 2021 at 15:02
2

For Mac in JupyterLab just press tab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.