generic_user
generic_user

Reputation: 3562

Possible to get pycharm-style "run with Python Console" functionality in VSCode?

In PyCharm, there's a handy button next to if __name__... statements that runs a script,

enter image description here

with configurations for the run in a run configurations menu.

One of the options is to "Run with Python Console":

enter image description here

This is really handy, because I can run my in-progress script in the console without ponderously highlighting and ctrl-entering. I'm then in the console, with everything I just did in memory, and I can go and continue writing my code using the REPL to check how things are working along the way.

In VScode, when I hit the run button

enter image description here

It just runs the script from the terminal. I can see any output that it prints, but it doesn't drop me into a REPL interface like I'm accustomed with PyCharm.

Is this sort of functionality attainable with VSCode?

Upvotes: 2

Views: 1908

Answers (2)

fburghardt
fburghardt

Reputation: 33

I've been looking for exactly the same functionality. Following two other stackoverflow posts you can get the desired behaivor -> executing in an REPL ipython terminal (original links at the end of the post):

edit the terminal launchArgs in settings.json (Preference: Open Settings JSON; or Preference -> Settings -> Search launchArgs -> edit in json):

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

Reference Links:

Upvotes: 2

Steven-MSFT
Steven-MSFT

Reputation: 8421

VSCode without this functionality, but it has some similar functionalities:

  1. Ctrl+A -> rightclick -> Run Selection/Line in Python Terminal.
  2. rightclick -> Run Current File in Interactive Window

Upvotes: 2

Related Questions