Visual Studio Code supports lots of languages including Python.Visual Studio Code provides different extensions for working with different languages such as C# and JavaScript. To develop and run a python program in Visual Studio Code we need to install Python extension for Visual Studio Code.
- Install a version of Python 3.Python programs need Python interpreter to execute.
- Install the Python extension for VS Code.In Visual Studio Code search for Python extension for VS Code.
- Include the location of your Python interpreter is included in your PATH environment variable.
- In Visual Studio Code select the Python interpreter from the command pallete(Ctrl+Shift+P) using the following command:
Python: Select Interpreter
Once you complete the above steps you are ready to execute Python applications in Visual Studio Code.
Create a new file test.py, and open in the editor.Type the following in the sample file:
msg = "Hello World" print(msg)
By using the .py file extension, VS Code interprets this file as Python and evaluates the contents with the Python extension and the selected interpreter.
To run test.py right-click the file in the editor and select Run Python File in Terminal.