在VS Code中使用IPython REPL [英] Use IPython REPL in VS Code

查看:4839
本文介绍了在VS Code中使用IPython REPL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Visual Studio Code的Python扩展,我可以选择一些代码,右键单击它,然后选择在Python终端中运行选择/行(或者,我可以按Shift + Enter)。但是,这会将所选代码发送到终端窗格中的普通旧Python REPL,而我希望此代码在IPython中运行(而不是QtConsole,只是基于终端的IPython)。

Using the Python extension of Visual Studio Code, I can select some code, right-click it, and select "Run Selection/Line in Python Terminal" (alternatively, I can hit Shift+Enter). However, this sends the selected code to a plain old Python REPL in the Terminal pane, whereas I'd like to have this code run in IPython instead (not the QtConsole, just the terminal-based IPython).

是否可以将IPython设置为默认REPL?我尝试将 / usr / local / bin / ipython3 设置为我的默认Python环境,但这不起作用(它仍然执行普通的Python解释器)。 FWIW,我在MacOS上。

Is it possible to set IPython as the default REPL? I tried setting /usr/local/bin/ipython3 as my default Python environment, but that doesn't work (it still executes the plain Python interpreter). FWIW, I'm on macOS.

推荐答案

在终端窗口中键入Ipython。然后从编辑器窗口中选择要运行的一行或多行,然后单击VScode窗口顶部的终端菜单。终端菜单中的一个选项是运行所选文本。这将在Ipython终端窗口中运行。我不知道如何使它成为默认值,但它似乎保持在该状态,除非Ipython停止。注意:您必须使用菜单项运行选择。在编辑器窗口中单击鼠标右键并单击运行选择将不会使用Ipython窗口。我希望这很清楚。如果不只是发表评论。

Type Ipython inside the terminal window. Then select the line or lines you want to run from the editor window and then click on the Terminal menu at the top of VScode window. One option in the Terminal menu is to "Run Selected Text". This will be run in the Ipython terminal window. I don't know how to make this the default but it appears to remain in that state unless Ipython is stopped. Note: You have to run your selections using the Menu item. Right-clicking in the editor window and clicking on "Run Selection" will not use the Ipython window. I hope this is clear. If not just drop a comment.

这篇关于在VS Code中使用IPython REPL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆