Use IPython REPL in VS Code

前端 未结 6 1381
天涯浪人
天涯浪人 2020-12-29 04:15

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 Shif

6条回答
  •  隐瞒了意图╮
    2020-12-29 04:42

    Adding the following setting (Preference: Open Settings JSON; or Preference -> Settings -> Search launchArgs -> edit in json) works without any extension. It also fixes the issue that multiple lines cannot be sent to Python.

    "python.terminal.launchArgs": [
        "-c",
        "\"import subprocess; subprocess.call(['ipython', '--no-autoindent'])\""
    ],
    

    Update (2020-12-27): the following setting seems to work better because it supports Ctrl+C keyboard interrupt without existing IPython:

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

提交回复
热议问题