Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete not working #2435

Closed
oztalha opened this issue Apr 22, 2017 · 84 comments
Closed

Autocomplete not working #2435

oztalha opened this issue Apr 22, 2017 · 84 comments

Comments

@oztalha
Copy link

oztalha commented Apr 22, 2017

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.

@takluyver
Copy link
Member

That sounds like it's taking a very long time to find the possible completions, and execution is getting held up behind the completion code. Can you check:

import IPython
print(IPython.sys_info())

@Carreau if IPython 6 is involved, it sounds like the timeout for jedi completions might not be working.

@oztalha
Copy link
Author

oztalha commented Apr 24, 2017

Exactly, it takes too long, and it is IPython 6.0.0.

{'commit_hash': '51ce9d73b',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/usr/local/lib/python3.6/site-packages/IPython',
 'ipython_version': '6.0.0',
 'os_name': 'posix',
 'platform': 'Darwin-16.5.0-x86_64-i386-64bit',
 'sys_executable': '/usr/local/opt/python3/bin/python3.6',
 'sys_platform': 'darwin',
 'sys_version': '3.6.1 (default, Apr  4 2017, 09:40:21) \n'
                '[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]'}

@oztalha
Copy link
Author

oztalha commented May 3, 2017

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.

@takluyver
Copy link
Member

There isn't a way to turn off autocompletion altogether. If I'm right about jedi being the problem, it may be possible to turn off the part that uses jedi. But I'm confused about whether or not the kernel completions actually use jedi (@Carreau?). You're not the only person having problems; see issues on ipython/ipython for more info.

@oztalha
Copy link
Author

oztalha commented May 8, 2017

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.

@takluyver takluyver added this to the Not Notebook milestone May 9, 2017
@jdlee23
Copy link

jdlee23 commented May 14, 2017

i'm having the same issue once i updated all my packages with conda. tab seems to crash my kernal. bit of a hard habit to kill haha

@takluyver
Copy link
Member

@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.

@jdlee23
Copy link

jdlee23 commented May 15, 2017

@takluyver ah thank you!

@lzkelley
Copy link

lzkelley commented Sep 19, 2017

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)]'}

@AndersMunkN
Copy link

I'm having the same issue on a windows server running windows server 2012R2. Whenever I tab it takes a random amount of time for anything to happen. If I keep writing and commit the cell, nothing happens and it often just does not respond.

Manually typed selected output below (like our forefathers did it)

{'commit_source': 'installation',
'default_encoding': 'cp1252',
'ipython_version': '6.1.0',
'os_name': 'nt',
'platform': 'Windows-2012ServerR2-6.3.9600-SP0',
'sys_platform': 'win32',
'sys_version': '3.5.4 |Anaconda custom (64-bit)| (default, Aug 14 2017, '
'13:41:13) [MSC v.1900 64 bit (AMD64)]' }

@rabernat
Copy link

I am suddenly and inexplicably having a similar problem. I am used to using tab autocomplete a LOT. Now, when I try to autocomplete from within jupyter notebook or lab, the kernel activity button briefly flashes, but nothing happens. No autocomplete.

I have no idea how to debug or fix this. It is extremely hard to use my notebooks without tab autocomplete.

'commit_hash': 'b65d977c8',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/Users/rpa/anaconda/envs/geo_scipy/lib/python3.6/site-packages/IPython',
 'ipython_version': '6.2.0.dev',
 'os_name': 'posix',
 'platform': 'Darwin-17.4.0-x86_64-i386-64bit',
 'sys_executable': '/Users/rpa/anaconda/envs/geo_scipy/bin/python',
 'sys_platform': 'darwin',
 'sys_version': '3.6.2 | packaged by conda-forge | (default, Jul 23 2017, '
                '23:01:38) \n'
                '[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]'}

@takluyver
Copy link
Member

Have you tried shutting down the server and starting it again? Do you still have tab completions if you use IPython in a terminal?

@rabernat
Copy link

Thanks for your reply!

Have you tried shutting down the server and starting it again?

Yes. No effect.

Do you still have tab completions if you use IPython in a terminal?

Yes.

@rabernat
Copy link

I have also tried from a different browser (Safari instead of Chrome).

@takluyver
Copy link
Member

What about if you use one of the other Jupyter frontends, like jupyter qtconsole?

@rabernat
Copy link

I resolved this by upgrading to ipython version 6.2.1.

@alvinwt
Copy link

alvinwt commented Apr 5, 2018

I've seen a similar problem with IPython 6.3.0. Using it with pandas 0.22 breaks auto completion for pandas column names. Rolling back to 6.2 returns the auto completion. I'm using jedi 0.11.1 but I think the behavior depends on IPython versions more.

@takluyver
Copy link
Member

We switched off our own completions by default for 6.3 to better test the completions we get from Jedi, and there are still some problems with those. I may need to make 6.3.1 to switch back to our own completions.

In the meantime, you can configure it with Completer.use_jedi = False.

@takluyver
Copy link
Member

I've made a 6.3.1 release.

@dstanner
Copy link

dstanner commented Aug 4, 2018

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!

@pavelpe
Copy link

pavelpe commented Nov 21, 2018

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.

@golobor
Copy link

golobor commented Dec 3, 2018

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.

@lodagro
Copy link

lodagro commented Dec 7, 2018

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]'}

@golobor
Copy link

golobor commented Dec 7, 2018

thanks! disabling jedi helped

@bnaul
Copy link

bnaul commented Dec 9, 2018

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.

@sergiosilvar
Copy link

sergiosilvar commented Dec 15, 2018

Just to let you know that I installed Jupyter recently and got victim of this TAB issue.

The workaround disabling Jedi autocompletion fixed the problem.

Info shows the same commit_hash and ipython_version posted by @lodagro:

{'commit_hash': '523ed2fe5',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '~/miniconda3/envs/budget/lib/python3.6/site-packages/IPython',
 'ipython_version': '7.2.0',
 'os_name': 'posix',
 'platform': 'Darwin-18.2.0-x86_64-i386-64bit',
 'sys_executable': '/Users/sergio/miniconda3/envs/budget/bin/python',
 'sys_platform': 'darwin',
 'sys_version': '3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 14:01:38) \n'
                '[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]'}

@lodagro
Copy link

lodagro commented Dec 18, 2018

@bnaul a suggestion to setup a minimal example to try to reproduce your issue

Full test documentaion see jedi test docs

In my case this is 100% Jedi. I added a test to my local jedi clone and could reproduce the issue (IPython is not involoved). Unfortunately i can not open an issue since code is proprietary.

@davidhalter
Copy link

Can you try it in IPython? I don't use Jupyter Notebook, so it's pretty hard for me to reproduce.

What I do is this: plt.figure().<tab> (and it works for me).

@mxposed
Copy link

mxposed commented Apr 18, 2020

ipython=7.13.0

Does not work in IPython either, it shows me completion for 3 files I have in that directory that start with a dot

@davidhalter
Copy link

Please run this then:

import matplotlib.pyplot as plt
import jedi, sys
import numpy, numpydoc
print(jedi.__version__, sys.version_info, numpy.__version__, numpydoc.__version__)
jedi.set_debug_function()
print(jedi.Interpreter('plt.figure().', [globals()]).completions())

@mxposed
Copy link

mxposed commented Apr 18, 2020

Wow, there's a ton of debug output.

0.17.0 sys.version_info(major=3, minor=7, micro=1, releaselevel='final', serial=0) 1.18.2 0.9.2

debug at https://gist.github.com/mxposed/cef09aa3cfd05433a67e954b7b61b2e5

[]
``

@davidhalter
Copy link

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).

@gph82
Copy link

gph82 commented Jul 2, 2020

Hi I think I'm bumping into @mxposed same error but on numpy:

  • Cell 1
import numpy as np
  • Cell 2
a = np.array([1,2])
a.d

(doesn't autocomplete)

  • Cell 3
a.dot

(autocompleted)
Below are the versions of the relevant (i think) packages...just checking if this could be similar.
Thanks in advance!

# Name                    Version                   Build  Channel
numpy                     1.18.5           py37ha1c710e_0  
numpy-base                1.18.5           py37hde5b4d6_0  
numpydoc                  1.0.0                    pypi_0    pypi
jedi                      0.17.1                   py37_0  
ipython                   7.16.1           py37h5ca1d4c_0  

EDIT: I am aware that disabling jedi is a workaround (I read the whole issue)

@davidhalter
Copy link

EDIT: I am aware that disabling jedi is a workaround (I read the whole issue)

I don't think this actually works. Disabling Jedi won't help in this case, because a does not exist at that point (I might be mistaken about this, since I don't know exactly how jupyter works). If it actually was defined, Jedi would use the definition and find completions (like what happens in cell 3).

@takluyver @Carreau I'm in favor of closing this issue. The original issue was probably resolved. You could then tag me in newer issues. But this issue serves now as a general autocompletion issue with different people complaining about different things (that were partially fixed a while ago). So I'm in favor of closing. Your call.

@gph82
Copy link

gph82 commented Jul 2, 2020

@davidhalter the cell nr. 2 has been already executed, and disabling jedi does work. Feel free to close the issue, just thought I'd complete with correct information.

@Carreau
Copy link
Member

Carreau commented Jul 2, 2020

Closing this for now then, and we can open a separate issue if necessary:

In [10]: import jedi
    ...: import numpy as np
    ...: jedi.Interpreter('arr = np.array([1,2])\narr.', [{'np':np}]).complete(2,4)
Out[10]: [] # expect something like `sum()`

@davidhalter
Copy link

davidhalter commented Jul 3, 2020

@Carreau I guess it should be more like jedi.Interpreter('arr = np.array([1,2])\narr.', [{'np':np, 'arr': arr}]).complete(2,4)

Which surprisingly to me doesn't work, it's a bug in Jedi. Opened davidhalter/jedi#1628 in favor of this ticket.

Also feel free to tag me whenever these kind of issues come up.

@gph82
Copy link

gph82 commented Jul 3, 2020

Thanks a lot @davidhalter for taking care of this, jedi is awesome!

@semaraugusto
Copy link

I had the same problem. I use pyenv and discovered that jupyter does not search at pyenv's repository for jedi files. Thus, if you use pyenv, you need to install jedi on your local python instalation

@cleebp
Copy link

cleebp commented Nov 13, 2020

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

@imkeines
Copy link

imkeines commented Dec 18, 2020

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

@iameru
Copy link

iameru commented Dec 27, 2020

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.

@davidhalter
Copy link

This is a different issue. It's essentially this issue: ipython/ipython#12740

As a temporary solution use:

pip install jedi==0.17.2

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

@rsgoodwin
Copy link

rsgoodwin commented Jan 3, 2021

@davidhalter Downgrading jedi from 0.18 to 0.17.2 worked for me. Thanks for posting here and referencing the jedi issue.

@prashantkg96
Copy link

@davidhalter yep downgrading Jedi worked for me too. Thanks!!!

@jernest1
Copy link

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"

@hawkuu
Copy link

hawkuu commented Apr 2, 2021

This is a different issue. It's essentially this issue: ipython/ipython#12740

As a temporary solution use:

pip install jedi==0.17.2

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

Thanks a lot, it works for me!

@ibilgen
Copy link

ibilgen commented Apr 6, 2021

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'

@ibilgen
Copy link

ibilgen commented Apr 6, 2021

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

@dsholes
Copy link

dsholes commented May 19, 2021

For those using Jupyterlab and who have many kernels associated with conda environments, just wanted to add that you need to install jedi==0.17.2 in each kernel (conda environment), not just your base environment that contains jupyter lab.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests