Issue
Visual Studio Code was recently released and I liked the look of it and the features it offered, so I figured I would give it a go.
I downloaded the application from the downloads page, fired it up, messed around a bit with some of the features ... and then realized I had no idea how to actually execute any of my Python code!
I really like the look and feel/usability/features of Visual Studio Code, but I can't seem to find out how to run my Python code, a real killer because that's what I program primarily in.
Is there is a way to execute Python code in Visual Studio Code?
Solution
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).
Answered By - python_starter
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.