python Shift+enter不能使用jupyter在VScode中工作

2024-10-02 00:30:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我安装了一个新的VS代码版本1.50.1,带有python扩展,现在添加了Jupyter扩展。Jupyter扩展版本号为2020.12.411183115。当我按shift键时,默认情况下,它会在下面添加一个新行。您可以在视频中看到,shift+enter应该可以运行该行。此时,在交互式窗口中运行代码的唯一方法是使用ctrl+shift+p并选择RunSelected cell

在与Danny Varod合作后编辑以下评论:
将键盘快捷键更改为ctrl+enter时,不会发生任何事情(不会在下面添加新行)。我按ctrl+shift+p,我看到正确的快捷方式是crtl+enter,但它不会触发操作

enter image description here

这是更改前我的键盘快捷键的屏幕截图

enter image description here

更改我的键盘快捷键以匹配下面的注释。现在,当我按下ctrl+enter键时,什么也没有发生

enter image description here


Tags: 方法代码版本视频shift版本号情况cell
3条回答

settings.json.vscode下添加以下行:

"jupyter.sendSelectionToInteractiveWindow": true

那么Shift+Enter就应该起作用了

请使用以下快捷键设置:

{ "key": "shift+enter",           "command": "jupyter.execSelectionInteractive", "when": "editorTextFocus"
},

此快捷键是根据使用条件设置的,只有在确认(包括打开控制面板)后才能使用。因此,我们可以删除此快捷键的使用条件

enter image description here

Shift+Enter还为我插入了一行新行,取消映射阻止了这一点

我将映射更改为:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

然而,这些映射对我来说是有效的,在Jupyter笔记本(.ipynb)中,Ctrl+EnterShift+Enter与我定义的进行了交换🤔.

此外,我正在使用以下Python扩展:

  • “MagicPython”magicstack.magicpython
  • “Jupyter”ms-toolsai.jupyter

两者均由安装者安装:

  • “Python扩展包”donjayamanne.python-extension-pack

当我打开.ipynb文件时,它们会作为Jupyter笔记本打开。 当我打开.py文件时,我可以使用Jupyter或MagicPython(或者说Python)

enter image description here

enter image description here

相关问题 更多 >

    热门问题