如何将ipython / jupyter设置为vscode的默认python终端?

时间:2018-10-02 19:48:40

标签: python visual-studio-code ipython jupyter

如何选择ipython / jupyter作为DEFAULT python终端?我将Windows 10和Linux计算机与anaconda一起使用。

如果我在终端上键入“ ipython”,它将打开一个ipython会话。如果运行调试器或Shift + Enter一行,它将自动在“准系统” python外壳程序上运行。应该很简单...但是我一直在搜索和弄乱设置半小时,没有成功。

查找

https://code.visualstudio.com/docs/python/tutorial-flask

Use IPython REPL in VS Code

但是找不到在我的linux或win10机器上进行设置的方法。有什么想法吗?

3 个答案:

答案 0 :(得分:6)

获得@TwoUnderscorez答案的一种稍微整洁的方法是仅使用-m IPython启动模块:

"python.terminal.launchArgs": [
   "-m",
   "IPython"
]

编辑:对于遇到IndentationError: unexpected indent错误的人,请尝试以下操作:

"python.terminal.launchArgs": [
   "-m",
   "IPython",
   "--no-autoindent",
]

(不会在现有答案中添加评论,但代表人数不足)

答案 1 :(得分:1)

当前不支持指定不是您用来执行代码的Python解释器的替代REPL。如果您只是想将代码发送给REPL,某些人会做的一个窍门是,他们一次启动REPL,退出,然后手动启动ipython,因为扩展程序将继续使用该终端实例来发送将来的代码。 REPL。

答案 2 :(得分:1)

  1. 在您的VSCode中,按 ctrl + shift + P ,开始输入设置,然后点击首选项:打开设置(JSON) >

  2. 添加此键值对以告诉python启动ipython:

    "python.terminal.launchArgs": [
        "-c",
        "\"from IPython import start_ipython; start_ipython()\""
    ]
    
相关问题