3

I'm using Visual Studio Code, and I'd like to have a REPL that I can run single Python instructions in. I've found some year-old Microsoft documentation on this that says select the View > Other Windows > Interactive menu item, but there is no Other Windows item in my version of VS Code (1.44.2).

Does VS Code have a REPL feature, or do I have to run python.exe directly from the Terminal pane?

0

2 Answers 2

6

You are looking at the wrong documentation. That's for Visual Studio, not Visual Studio Code. They are annoyingly similarly named, which can be confusing, but they are two completely different IDEs.

The correct docs for VS Code is here:
https://code.visualstudio.com/docs/languages/python

There is a section for running Python codes on the Terminal:
https://code.visualstudio.com/docs/languages/python#_run-python-code

You can use the standard Python console.

  1. Install the Python extension for VS Code
  2. Setup and select the correct Python environment
    • Open the Command Palette then "Python: Select Interpreter" enter image description here
  3. Next, highlight the line you want to run, then right-click
  4. Select the Run Selection/Line in Python Terminal enter image description here
  5. It should open up a Terminal panel and run your code in Python console enter image description here
  6. You can then keep right-clicking > Run and it will execute on the same session

There's also an option to run the entire file.

See the Run Python Code section of the docs for more info.

1

enter image description here

You can open the command palette and enter python: Start REPL

This will open the REPL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.