Here is how to configure Task Runner in Visual Studio Code to run a .py file.

In your console, press Ctrl + Shift + P (Windows) or Cmd + Shift + P (Apple). This brings up a search box where you search for "Configure Task Runner"

If this is the first time you open the "Task: Configure Task Runner", you need to select "other" at the bottom of the next selection list.

This will bring up the properties which you can then change to suit your preference. In this case you want to change the following properties;

  1. Change the Command property from "tsc" (TypeScript) to "Python"
  2. Change showOutput from "silent" to "Always"
  3. Change args (Arguments) from ["Helloworld.ts"] to ["${file}"] (filename)
  4. Delete the last property problemMatcher
  5. Save the changes made

You can now open your .py file and run it nicely with the shortcut Ctrl + Shift + B (Windows) or Cmd + Shift + B (Apple).

Answer from python_starter on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › python › python-tutorial
Getting Started with Python in VS Code
November 3, 2021 - From the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)), select the Python: Start Terminal REPL command to open a REPL terminal (notated by >>>) for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time. Congrats, you just ran your first Python code in Visual Studio Code!
🌐
Visual Studio Code
code.visualstudio.com › docs › python › python-quick-start
Quick Start Guide for Python in VS Code
November 3, 2021 - From the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)), select the Python: Start REPL command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.
Discussions

How to execute Python code from within Visual Studio Code - Stack Overflow
Is there is a way to execute Python code in Visual Studio Code? ... Save this answer. ... Show activity on this post. Here is how to configure Task Runner in Visual Studio Code to run a .py file. More on stackoverflow.com
🌐 stackoverflow.com
Preferred method to run python in VS Code
🌐 r/Python
86
137
May 28, 2024
How to set up python on vs code
I would suggest that you start off with Thonny IDE, as it requires virtually no "setting up", and even includes Python so that you don't need to set up Python either. It's a great IDE for beginners. When you have outgrown Thonny you will know a lot more about Python, so setting up vscode or PyCharm should be a lot easier for you. More on reddit.com
🌐 r/learnpython
13
10
October 17, 2024
Is vscode a good IDE for Python?
🌐 r/learnpython
161
133
October 24, 2023
🌐
Visual Studio Code
code.visualstudio.com › docs › python › run
Running Python code in Visual Studio Code
November 3, 2021 - Select one or more lines, then press Shift+Enter, or right-click and select Run Selection/Line in Python Terminal. This option is convenient for testing just a part of a file. Place your cursor on a line of code and press Shift+Enter to activate ...
🌐
Visual Studio Code
code.visualstudio.com › docs › languages › python
Python in Visual Studio Code
November 3, 2021 - You must install a Python interpreter yourself separately from the extension. For a quick install, use Python from python.org and install the extension from the VS Code Marketplace.
🌐
GeeksforGeeks
geeksforgeeks.org › python › run-python-file-in-vscode
Run Python File In Vscode - GeeksforGeeks
July 23, 2025 - We can run our Python program inside the Python file using the Play button given on the right of the Visual Studio Code as given in the below picture.
🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › python › tutorial-working-with-python-in-visual-studio-step-02-writing-code
Tutorial: Write and run Python code in Visual Studio
Explore options specific to working with Python in Visual Studio: ... To see options that apply to all supported programming languages, select Tools > Options > Text Editor > All Languages. After you have some code in place, you're ready to try running your program.
Find elsewhere
🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › python › quickstart-05-python-visual-studio-open-folder
Quickstart: Open and Run Python Code in a Folder - Visual Studio (Windows) | Microsoft Learn
May 29, 2026 - You can also select the solid play arrow next to the Startup Item name on the Visual Studio toolbar. This option runs the code in the Visual Studio Debugger. For all of these start methods, Visual Studio detects that your Startup Item is a Python ...
🌐
YouTube
youtube.com › the code city
How to Run Python File in Visual Studio Code | Run Python in VSCode - YouTube
In this video, I'll show you how to run python file in visual studio code.You need to install code runner to run python files in visual studio code. If you d...
Published: November 15, 2023
Views: 102K
🌐
OpenSourceOptions
opensourceoptions.com › 4-ways-to-run-python-code-in-visual-studio-code
4 Ways to Run Python Code in Visual Studio Code – OpenSourceOptions
Once you have the proper environment set, right-click on the file you want to run (remember in the File Explorer, not Open Editors) and select ‘Run Python File in Terminal’. This command will open a terminal inside of the Visual Studio Code IDE, activate the Python environment you’ve selected, and run the Python script.
🌐
DataCamp
datacamp.com › tutorial › setting-up-vscode-python
Setting Up VSCode For Python: A Complete Guide | DataCamp
December 3, 2024 - Note: Most Python development extensions and features come with Python extensions. Visual Studio Code allows users to simply run the data science code in Jupyter Notebook. We can run the cell and visualize the result within VSCode.
🌐
Reddit
reddit.com › r/python › preferred method to run python in vs code
r/Python on Reddit: Preferred method to run python in VS Code
May 28, 2024 -

Been working on a python tool for VS Code. Curious to get peoples' opinion on how they run python files (not notebooks) within VS Code. Do you typically run files python by:

  • Typing the python command into the integrated terminal

  • Clicking the run button at the top of the file

  • Pressing F5 for debugging

  • Pressing Ctrl+F5 for run but not debug

  • Creating a custom keyboard shortcut

  • Other

Let me know your thoughts, I appreciate the insights!

🌐
Python Land
python.land › home › creating python programs › python in vscode: running and debugging
Python in VSCode: Running and Debugging • Python Land Tutorial
September 5, 2025 - I deliberately made a mistake that we will try to debug later on. To run this file, you can either use the menu Run -> Run Without Debugging or press Control + F5 (Windows and Linux) or cmd + F5 (MacOS).
🌐
Real Python
realpython.com › python-development-visual-studio-code
Python Development in Visual Studio Code – Real Python
July 3, 2026 - There is no need to leave the editor to do this: Visual Studio Code can run this program directly in the editor. Save the file (using Ctrl+S), then right-click in the editor window and select Run Python File in Terminal:
🌐
Quora
quora.com › How-do-I-run-Python-in-Visual-Studio-Code
How to run Python in Visual Studio Code - Quora
Answer: No configuration is needed at all. Just install the required version of Python or do the installation by Anaconda distribution. Make a .py file in VS editor or by the normal way, when your code station a python file for the first time it will itself recommend you to have the required Pyth...
🌐
GitHub
github.com › microsoft › vscode-python › discussions › 20279
how to properly Run python code in VSCode? · microsoft/vscode-python · Discussion #20279
Hello, I know that officially to Run a Python code I should a) click the upper right corner icon "▷" Run Python File or b) right click in the editor and from the context menu choose: "Run Python File in Terminal"
Author: microsoft
🌐
MarkTechPost
marktechpost.com › home › tutorials › basic tutorials › a beginners guide to using visual studio code for python
A Beginners Guide to Using Visual Studio Code for Python - MarkTechPost
March 29, 2025 - We began by installing VSCode and the Python extension, selecting the appropriate Python interpreter, and creating our first Python script. We learned how to run and debug Python code using both the Run button and the integrated terminal, and saw how breakpoints and the debugger help identify issues in our code.
🌐
YouTube
youtube.com › watch
How to Setup Python In Visual Studio Code Full Guide - YouTube
In this Visual Studio Code tutorial, learn how to setup, create, and run a Python project. We walk through some code, some packages, and how to run it all wi...
Published: October 11, 2024