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;
- Change the Command property from
"tsc"(TypeScript) to"Python" - Change showOutput from
"silent"to"Always" - Change
args(Arguments) from["Helloworld.ts"]to["${file}"](filename) - Delete the last property
problemMatcher - 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 OverflowHow to execute Python code from within Visual Studio Code - Stack Overflow
Preferred method to run python in VS Code
How to set up python on vs code
Is vscode a good IDE for Python?
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;
- Change the Command property from
"tsc"(TypeScript) to"Python" - Change showOutput from
"silent"to"Always" - Change
args(Arguments) from["Helloworld.ts"]to["${file}"](filename) - Delete the last property
problemMatcher - 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).
All these answers are obsolete now.
Currently you have to:
- install the Python language extension (and Python, obviously)
- open folder (important!), open any Python file inside that folder
- switch to debug "tab"(?) and click on the gearbox (with hint 'Configure of Fix 'launch.json'')
- save the opened launch.json file (it's placed in .vscode subdirectory in the folder opened in step #2)
- finally, click the green triangle or hit F5
No additional extensions or manual launch.json editing is required now.
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!
Hi. I am new to Programming and I decided to start my learning journey with cs50 python. Sadly I live in a war zone and I don't always have access to internet. I cannot use the online interface for the course everyday so I want to be able to work offline sometimes. I installed vs code but it always tell me that python is not present. I don't really understand the tutorials I saw online and I would appreciate any help