jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.75k stars 4.99k forks source link

Autocomplete not working #2435

Closed oztalha closed 4 years ago

oztalha commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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.

jdlee23 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

@takluyver ah thank you!

lzkelley commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

takluyver commented 6 years ago

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

rabernat commented 6 years ago

I resolved this by upgrading to ipython version 6.2.1.

alvinwt commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

I've made a 6.3.1 release.

dstanner commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

thanks! disabling jedi helped

bnaul commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

zpincus commented 5 years ago

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.

RobinFrcd commented 5 years ago

Hi, Same issue here with my jupyter lab/notebook inside a docker.

I've this config inside my /etc/jupyter/jupyter_notebook_config.py.

c = get_config()
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
c.NotebookApp.token = ''
c.Completer.use_jedi = False

# https://github.com/jupyter/notebook/issues/3130
c.FileContentsManager.delete_to_trash = False

With:

{'commit_hash': '523ed2fe5',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/opt/conda/lib/python3.6/site-packages/IPython',
 'ipython_version': '7.2.0',
 'os_name': 'posix',
 'platform': 'Linux-4.4.0-140-generic-x86_64-with-debian-stretch-sid',
 'sys_executable': '/opt/conda/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.6.7 | packaged by conda-forge | (default, Nov 21 2018, '
                '03:09:43) \n'
                '[GCC 7.3.0]'}

Am I missing something ?

cdknorow commented 5 years ago

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
lodagro commented 5 years ago

@cdknorow Could you open an issue (including your testcase) in the davidhalter/jedi project?

davidhalter commented 5 years ago

For the case of autocompleting properties, please look at my comment here:

https://github.com/davidhalter/jedi/issues/1299#issuecomment-475369943

TLDR; use_jedi=False is not safe, but has more completions, Jedi is safe (no side effects) but currently doesn't return anything when completion on property results.

AkiraCharles commented 5 years ago

Hi. I am having an issue as well using TAB within Jupyter. when I attempt to call a method off of a Dataframe within the Jupyter Notebook , I am trying to add the ".Unique()" method. But, when I attempt to call whatever methods may be available off of the dataframe object, the only thing that appears is "ipynb_checkpoints/". I have googled this issue but I cannot seem to find a way to resolve it. Does anyone have any advice on this? I tried uninstalling and reinstalling Anaconda and that does not solve the issue.

AkiraCharles commented 5 years ago

Capture

davidhalter commented 5 years ago

Where are you exactly trying to complete?

AkiraCharles commented 5 years ago

Sorry David. I don't understand your question. "Where are you exactly trying to complete?"

But I am working with a pandas Dataframe...practicing. When I noticed that when I typed in "df['col2']." <------ then attempt to call a method by hitting TAB....the notebook takes a while to load then "ipynb_checkpoints/" appears.

cdknorow commented 5 years ago

It won't auto complete off an object like that. You should try, df.col2.

On Fri, Apr 12, 2019, 3:40 PM Dave Halter notifications@github.com wrote:

Where are you exactly trying to complete?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jupyter/notebook/issues/2435#issuecomment-482744260, or mute the thread https://github.com/notifications/unsubscribe-auth/AA1-yPoOFs7D2CdnUMMrIQY0lT3rH1rSks5vgQtJgaJpZM4NFO2M .

AkiraCharles commented 5 years ago

Hi, thanks for the reply, the methods I get when I write the syntax like that are not the methods I expect to get. I expect to see methods like ".unique" or ".value_counts"

davidhalter commented 5 years ago

@AkiraCharles Yeah that won't work usually. There's just too much magic involved to get that working. If you want autocompletions just use x = df['col2']; x.<tab>.

AkiraCharles commented 5 years ago

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

SamGrah commented 5 years ago

In addition to the autocomplete issue, I wasn't able to launch Jupyter Labs in Windows.

Disabling jedi fixed both of these issues for me.

Windows 10 Enterprise Python r3.8 Jupyter Lab 0.35.5 Jupyter Notebook 5.7.4

BrenBarn commented 5 years ago

I don't fully understand why there is such resistance to simply evaluating the expression. 90% of the time I would prefer the autocompleter to evaluate as much of the expression as it can so that it can provide more comprehensive completions. There's no reason that completing df['col2']. requires "magic"; all it requires is to evaluate df['col2']. Yes, sometimes I may not want that if the expression is expensive to evaluate, but far more often the expression is cheap to evaluate and I care more about getting good completions.

Is there any way to tell Jedi/IPython to just go ahead and evaluate as much as it needs to in order to autocomplete on whatever I've actually typed? It would be kind of cool if there were a way to switch this behavior on and off to handle the rare cases where the expression is expensive, or if there were alternative keyboard shortcuts for the two kinds of completion.

lodagro commented 5 years ago

@BrenBarn concerning this resistance, see also https://github.com/davidhalter/jedi/issues/1299#issuecomment-475369943

davidhalter commented 5 years ago

There's no such switch as of now.

The problem with evaluation is that if you do it you do it for all cases, you quickly get into very nasty scenarios. I think Jedi does evaluation for dicts, so it works most of the time, but just not in cases like this one, where it's not a dict.

thorwhalen commented 4 years ago

It seems tab completion (for object attributes) is broken again. For me, it's not systematic, is some times just VERY slow, and it seems if I just start working in a new cell, it will work.

I'm

macOS Mojave Vesion 10.14.6
MacBook Pro (15-inch, 2018)
2.9 GHz Intel Core i9
32 GB 2400 MHz DDR4

Any solutions to this slight, but still very annoying regression?

thorwhalen commented 4 years ago

I've checked with two colleagues (one with a Mac, the other with Linux), and they both reported the same problem of tab completion not working all the time.

davidhalter commented 4 years ago

If you want this to improve, please post what's not working. In your case I have NO idea what's working and what's not. tab completion not working all the time could mean pretty much anything.

BrenBarn commented 4 years ago

@lodagro: I saw that, but later in that issue it says that the "safety" feature was disabled to provide more complete completions. Yet Jupyter still doesn't complete properties correctly.

@davidhalter: Here are some examples of what isn't working:

import pandas

x = pandas.DataFrame({"X": ['a', 'b', 'c']})

After this I should be able to do the following, none of which currently work right:

davidhalter commented 4 years ago

Related Issues:

It displays the autocompletions after hanging for about five seconds.

https://github.com/davidhalter/jedi/issues/520

x.X.

I'm pretty sure this is https://github.com/davidhalter/jedi/issues/1378


So I guess using pandas with Jedi is just a bit unfortunate and I currently don't really have a good solution for either problem.

BrenBarn commented 4 years ago

@davidhalter: One solution is to provide an evaluation-based completion method. (Maybe this is the safe=False method you mentioned on davidhalter/jedi#1378?) You asked here for people to explain what isn't working, so I'm giving examples. My point is that if jedi doesn't complete pandas accessors as in the examples I gave, that is perceived as "not working" by users.

I still don't fully understand why you think there's no solution. Isn't the solution to an evaluation-based completion mechanism? The main reason I've seen on jedi issue threads is that you're concerned about "safety", but as I mentioned on that issue, I think for many people that is at most a minor concern. (You seem to realize this too as you mentioned in davidhalter/jedi#1299 that you turned off a similar "safety" feature because people didn't want it.)