Issue
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).
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.
Solution
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",
],
Answered By - Feng Mai
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.