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?
Just click the Run Python File in Terminal play button in the top-right side of the editor. Select one or more lines, then press Shift+Enter or right-click and select Run Selection/Line in Python Terminal. This command is convenient for testing just a part of a file.
Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.
There is a much easier way to run Python, and it doesn't need any configuration:
If you want to add the Python path, you could go to File → Preference → Settings, and add the Python path like below:
"code-runner.executorMap": { "python": "\"C:\\Program Files\\Python35\\python.exe\" -u" }
In case you have installed the Python extension and manually set your interpreter already, you could configure your settings.json file as follows:
{ "python.pythonPath": "C:\\\\python36\\\\python36.exe", "code-runner.executorMap": { "python": "$pythonPath -u $fullFileName" } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With