notebook: Autocomplete not working

Installed Python (3.6) via brew, and the notebook (version 5.0.0) via pip3. When I hit tab, say, after df., nothing happens, then, when I manually complete df.head(), execution queued, and run after ~30 seconds. At the same time, suggestion drop-down menu appears.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 29
  • Comments: 84 (8 by maintainers)

Commits related to this issue

Most upvoted comments

This is a different issue. It’s essentially this issue: https://github.com/ipython/ipython/issues/12740

As a temporary solution use:

pip install jedi==0.17.2

As soon as IPython master is released, we’re fine.

Thank you. Adding the line c.Completer.use_jedi = False to the IPython configuration file solved the issue (so it appears that not only terminal completions but also kernel completions use Jedi). For future visitors having the same issue, setting configurable options is explained here.

Downgrading from jedi 0.18.0 to 0.17.2 fixed this issue for me in Windows. Just ran “pip install jedi==0.17.2”

Is there a way to turn off autocomplete? It not only slows me down but often also crashes the kernel? And I wonder if I am the only one having this issue on the planet? Thanks.

After an upgrade from 5.x to 7.2 IPython tab completion also fails on some objects in my environment. Currently as workaround using Completer.use_jedi = False

{'commit_hash': '523ed2fe5',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '<snip>/miniconda3-latest/lib/python3.6/site-packages/IPython',
 'ipython_version': '7.2.0',
 'os_name': 'posix',
 'platform': 'Linux-4.4.0-62-generic-x86_64-with-debian-stretch-sid',
 'sys_executable': '<snip>/miniconda3-latest/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:16:44) \n'
                '[GCC 7.3.0]'}

My (tab) autocomplete intermittently stops working, not sure if this is the same issue — it does not seem to be that it’s simply taking too long, it just never appears (nothing happens after hitting tab), but execution time remains the same. The problem continues until the kernel restarts. It might be related to significant amounts of data in active memory… but I’m not sure.

Any recommendations to further diagnose issue?

{‘commit_hash’: ‘d86648c5d’, ‘commit_source’: ‘installation’, ‘default_encoding’: ‘UTF-8’, ‘ipython_path’: ‘/Users/lzkelley/anaconda3/lib/python3.5/site-packages/IPython’, ‘ipython_version’: ‘6.1.0’, ‘os_name’: ‘posix’, ‘platform’: ‘Darwin-16.7.0-x86_64-i386-64bit’, ‘sys_executable’: ‘/Users/lzkelley/anaconda3/bin/python’, ‘sys_platform’: ‘darwin’, ‘sys_version’: '3.5.4 |Anaconda custom (x86_64)| (default, Aug 14 2017, ’ ‘12:43:10) \n’ ‘[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]’}

disabling Jedi also worked for me. Here is my test case where autocomplete was failing.


class Project():
    def __init__(self, name):
        self.name = name
    def foo(self):
        return
    def bar(self):
        return

class Client():
    @property
    def project(self):
        return self._project

    @project.setter
    def project(self, name):
        self._project = Project(name)

when trying to do autocomplete, with jedi disabled I am able to see the properties of Project with tab complete. Without it it just shows none.


c = Client()
c.project = ''
c.project.<tab>

starting ipython with

ipython --Completer.use_jedi=False

worked.

Also, adding a function that is called in the init of my class when it is instantiated, works as well

  def setup_jedi_false(self):
       """ This is a temporary bug fix in ipython autocomplete """
       try:
           mgc = get_ipython().magic
           mgc('%config Completer.use_jedi = False')
       except:
           pass

Once I specify a column in a dataframe, autocomplete no longer gives me informative options/attributes. E.g.,

screen shot 2018-08-04 at 4 27 01 pm

I’m having exact same issue. IPython is v7.1.1 with jedi 0.13.1 It just started happening w/o any particular reason or changes made. Tried to reinstall Jupyter, Python3, removing all global packages and removing project venv, downgrading notebook up to 4.2.3, even tried using JupyterLab but unsuccessfully.

Currently the only partial solution for me (it doesn’t fully solves the issue and tab-auto completion doesn’t auto-complete function parameters) is to use: %config IPCompleter.greedy=True

{ 'ipython_version': '7.1.1', 'os_name': 'posix', 'platform': 'Linux-4.4.0-134-generic-x86_64-with-Ubuntu-16.04-xenial', 'sys_platform': 'linux', 'sys_version': '3.6.7 (default, Oct 25 2018, 09:16:13) \n[GCC 5.4.0 20160609]' }

Using notebook w/o auto-complete is extremely difficult. Does anyone works on this issue? Because it opened for years. There are some issues of same problem that are marked as solved but nothing fixed. Very frustrating.

@danieljoonlee over on ipython/ipython#10560, there was a bug identified in the conda packages of jedi. Apparently conda-forge has a working version of the jedi package. If that doesn’t fix things for you, please file a new issue on IPython with the details.

I also had this problem oddly. Completion worked in a venv with jedi=0.17.2 . completion did not work with a new venv using 0.18 downgrading did the trick, this thread was a help.

I had this problem in a conda environment only. Disabling jedi by adding %config Completer.use_jedi = False to the JN helped.

same issue here! I suspect that, for me, autocompletion in Jupyter stopped working after I updated IPython from 5.3 to 7.2. Curiously enough, Jupyter still autocompletes dictionary keys, but not variables or class members.

I am also now having this problem, particularly with pandas dataframes.

Once I specify a column in a dataframe, autocomplete no longer gives me informative options/attributes. E.g.,

screen shot 2018-08-04 at 4 27 01 pm

IPython version is 6.4.0 jedi version is 0.12.1

Any help would be appreciated!

I resolved this by upgrading to ipython version 6.2.1.

Ran into this recently and just found this thread, upgrading to jedi=0.17.2 fixed our tab auto completion bug.

I finally found it. The problem is that matplotlib uses the following in its docstring now: figure : `~matplotlib.figure.Figure`.

In the older version I tested with, matplotlib used Figure, which Jedi was able to understand. IMO this is a matplotlib issue. They should probably just use annotations to clear this up (and make it possible for a lot of static analysis tools [including Jedi] to understand the return type).

I am having the same issue. It is because of Jedi as mentioned.

{'commit_hash': '95d2b79a2',
 'commit_source': 'installation',
 'default_encoding': 'utf-8',
 'ipython_path': '~/anaconda3/envs/ml_env/lib/python3.8/site-packages/IPython',
 'ipython_version': '7.18.1',
 'os_name': 'posix',
 'platform': 'Linux-5.4.0-70-generic-x86_64-with-glibc2.10',
 'sys_executable': '~anaconda3/envs/ml_env/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.8.8 (default, Feb 24 2021, 21:46:12) \n[GCC 7.3.0]'}
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/tornado/gen.py", line 762, in run
    value = future.result()
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/tornado/gen.py", line 234, in wrapper
    yielded = ctx_run(next, result)
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 583, in complete_request
    matches = yield gen.maybe_future(self.do_complete(code, cursor_pos))
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 360, in do_complete
    return self._experimental_do_complete(code, cursor_pos)
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 385, in _experimental_do_complete
    completions = list(_rectify_completions(code, raw_completions))
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/IPython/core/completer.py", line 484, in rectify_completions
    completions = list(completions)
  File "~/anaconda3/envs/ml_env/lib/python3.8/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 "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/IPython/core/completer.py", line 1861, in _completions
    matched_text, matches, matches_origin, jedi_matches = self._complete(
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/IPython/core/completer.py", line 2029, in _complete
    completions = self._jedi_matches(
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/IPython/core/completer.py", line 1373, in _jedi_matches
    interpreter = jedi.Interpreter(
  File "~/anaconda3/envs/ml_env/lib/python3.8/site-packages/jedi/api/__init__.py", line 725, in __init__
    super().__init__(code, environment=environment,
TypeError: __init__() got an unexpected keyword argument 'column'

Downgrading jedi as below solved my problem. This issue helped a lot. Thanks.

pip install jedi==0.17.2

@davidhalter Thanks for informing me! I’ve also only started learning Python (my first programing language) since January and this in my first time using Github. It’s awesome to see that people actually try to help you out here. hope I can do the same for others one day. Much Appreciated.

Just to chime in that after updating IPython to 7.2.0 from 7.0.2 (via Anaconda), I also had some objects fail to autocomplete. Setting Completer.use_jedi = False fixed the issue.

I’ve also had to disable jedi because the completions are too flaky, but I do miss the extra functionality; does anyone (cc @takluyver) have a suggestion for how to track down the issue/come up with a minimal example? Debuggers, etc. don’t seem to work now that IPython is async and I’m not sure how to test this outside of the REPL.

thanks! disabling jedi helped