问题:如何在Jupyter Notebook中获得自动完成功能而不使用制表符?

我想在笔记本中获得自动完成功能,即当我键入内容时,会出现一个下拉菜单,其中包含我可能键入的所有可能内容,而无需按Tab键。有这样的事吗?

我试过了 :

%config IPCompleter.greedy =真实

但这需要按下选项卡按钮

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


回答 0

有一个扩展名为Hinterland juterter的,在键入时会自动显示下拉菜单。还有一些其他有用的扩展。

为了安装扩展,您可以按照此github repo上的指南进行操作。要轻松激活扩展程序,您可能需要使用扩展程序配置器

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.


回答 1

即使使用了腹地扩展,使用Jupyter Notebook的自动完成功能也是如此弱。感谢您提供基于深度学习的代码自动完成的想法。我开发了基于TabNine的Jupyter Notebook扩展,该扩展提供了基于深度学习的代码自动完成功能。这是我的工作的Github链接:jupyter-tabnine

现在可以在pypi索引上使用。只需发出以下命令,然后使用它即可:)

pip3 install jupyter-tabnine
jupyter nbextension install --py jupyter_tabnine
jupyter nbextension enable --py jupyter_tabnine
jupyter serverextension enable --py jupyter_tabnine

演示

The 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_tabnine

demo


回答 2

如上面@physicsGuy所述,您可以使用内地扩展名。简单的步骤即可。

使用conda forge频道安装nbextension。只需在conda终端中运行以下命令:

conda install -c conda-forge jupyter_nbextensions_configurator

下一步启用腹地扩展。在conda终端中运行以下命令:

jupyter nbextension enable hinterland/hinterland

就这样,完成了。

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_configurator

Next Step enabling the hinterland extension. Run the below command in conda terminal:

jupyter nbextension enable hinterland/hinterland

That’s it, done.


回答 3

这样%config IPCompleter.greedy=True导入诸如numpy或pandas之类的软件包后,无需执行此操作; import numpy as np import pandas as pd

然后输入,pd.然后点击选项卡按钮,它会弹出所有可能的方法,以非常简单直接地使用。

Without doing this %config IPCompleter.greedy=True after you import a package like numpy or pandas in this way; import numpy as np import 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.


回答 4

我正在使用Jupiter Notebook 5.6.0。在这里,要获得自动提示,我只需输入至少一个字符后按Tab键即可。

 **Example:** Enter character `p` and hit Tab.

要在导入的库中获取方法和属性,请使用与Alice相同的Tab键

  import numpy as np

  np. --> Hit Tab key

I 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

回答 5

将以下内容添加到Jupyter Lab的键盘用户首选项中(设置->高级系统编辑器)

{
    "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"
        }

    ]
}

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"
        }

    ]
}

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。