代码之家  ›  专栏  ›  技术社区  ›  Frâncio Rodrigues

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

  •  1
  • Frâncio Rodrigues  · 技术社区  · 7 年前

    如何选择i python/jupyter作为默认的python终端?我使用的是windows 10和linux机器上的anaconda发行版。

    如果我在终端上键入“ipython”,它将打开ipython会话。如果我运行调试器或shift+enter一行,它将自动运行在“准骨骼”python shell上。应该很简单……但是我已经在谷歌上搜索了半个小时了,没有成功。

    抬起头

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

    Use IPython REPL in VS Code

    但在我的Linux或Win10机器上找不到设置它的方法。有什么想法吗?

    3 回复  |  直到 6 年前
        1
  •  1
  •   Daniel Puiu    6 年前
    1. 在您的vscode中,按 CTRL+Shift +P 开始键入 设置 然后点击 首选项:打开设置(JSON)

    2. 添加这个键值对,告诉python启动ipython:

      "python.terminal.launchArgs": [
          "-c",
          "\"from IPython import start_ipython; start_ipython()\""
      ]
      
        2
  •  3
  •   farenorth    6 年前

    要想获得@twounderscorez的答案,一个稍微简洁的方法是使用 -m IPython :

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

    编辑: 为任何与之抗争的人 IndentationError: unexpected indent 错误,请尝试以下操作:

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

    (不会对现有答案添加评论,但没有足够的代表)

        3
  •  1
  •   Brett Cannon    7 年前

    目前不支持指定一个替代repl,该repl不是用于执行代码的python解释器。如果你只想把代码发送到repl,有些人会做的一个技巧是,他们启动repl一次,退出它,然后启动 ipython 手动作为扩展将继续使用该终端实例作为将来发送到repl的代码。