[英]VS Code execute selection to IPython shell in terminal (no notebook)
I wanted to use IPython interactive in VSC (not using a notebook).我想在 VSC 中使用 IPython 交互(不使用笔记本)。 By using a keybiding for workbench.action.terminal.runSelectedText, I can successfully execute a selection to a python interactive shell, but with iPython it fails to run the cell and I have to change selection to the terminal and press enter.
通过对 workbench.action.terminal.runSelectedText 使用 keybiding,我可以成功地执行对 python 交互式 shell 的选择,但是使用 iPython 它无法运行单元格,我必须将选择更改为终端并按 Enter。
Here's my keybidings.json file:这是我的 keybidings.json 文件:
[
{
"key": "ctrl+enter",
"command": "workbench.action.terminal.runSelectedText"
}
]
Any help to solve this is much appreciated, Ideally.非常感谢任何帮助解决这个问题,理想情况下。 a keybinding configuration that includes an extra enter.
包含额外输入的键绑定配置。
IPython is not officially supported by the Python extension and this is part of the reason: IPython's design simply requires you to press Enter an extra time based on how VS Code sends text into the terminal. Python 扩展不正式支持 IPython,这也是部分原因:IPython 的设计只是要求您根据 VS Code 将文本发送到终端的方式多按一次 Enter。
I was annoyed by this quirk in vs-code too.我也对 vs-code 中的这个怪癖感到恼火。
I noticed that when using a python virtual environment (I use pipenv
) my selected line was executed in an Ipython
terminal and no extra Enter
key press was needed.我注意到,当使用 python 虚拟环境(我使用
pipenv
)时,我选择的行是在Ipython
终端中执行的,不需要额外的Enter
按键。
To reproduce or test out:重现或测试:
pipenv shell
(requires pip install pipenv && pipenv install ipython
)pipenv shell
(需要pip install pipenv && pipenv install ipython
)ipython
(or ipython --no-autoindent
)ipython
(或ipython --no-autoindent
)Terminal: Run Selected Text in Active Terminal
(or use a keyboard shortcut) Terminal: Run Selected Text in Active Terminal
(或使用键盘快捷键) screenshot of python window and terminal window python window 和终端 window 的屏幕截图
I have this problem when I upgraded IPython to version 7.30.1 The solution I found is that add "--simple-prompt"
, this is not perfect (just no color theme or auto completion), but at very least, you don't need to press enter when sending codes to run.当我将 IPython 升级到版本 7.30.1 时我遇到了这个问题我找到的解决方案是添加
"--simple-prompt"
,这并不完美(只是没有颜色主题或自动完成),但至少,你没有发送代码运行时无需回车。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.