How to Run Python Program in Visual Studio Code (Terminal)

If you want to use Visual studio code to create and run Python programs, this tutorial will definitely help you a lot.

Default python IDLE app is a complicated one for beginners. But don’t worry. There are a lot of 3rd party Python IDEs available like Pycharm community edition, Sublime Text, PyDev, etc.

VS Code is one of the best and free Python IDLE to create and run Python apps on your desktop.

run python in vs code

So, How to setup Visual Studio Code for Python

  1. First, make sure to download and install Python on your system.
  2. Then install VS code on your computer.
  3. In VS code editor, left sidebar, click the Extensions icon.
  4. Search and find the Python extension. Install it.
  5. Then in the left sidebar (explorer panel), right-click and create a new file and name the file with the .py extension (example program.py)Visual studio code workspace for python

Now write your first program.

Example:-

print("Good Morning")

6. Now click the play button on the right top corner of the VS code application.

7. It will print the “Good Morning” message in VS code terminal.

8. You can use VS code terminal like windows command prompt and install any python packages if you want using pip command.

You can do more things in VS Code when you create Python apps like,

  • Drag and drop project folder in left side workspace.
  • In  VS code, If you want to open a particular folder in a terminal like windows cd C;//Program files, just right-click the folder in VS code left sidebar and choose the “Open in integrated terminal” option.
  • You can also copy the folder or file path with the right-click command and choose “copy path” or “copy related path.
  • Working with a Virtual environment in VS code terminal is super easy.
  • you can also change to 4 Indent Spaces Instead Of Default 2 in VS code editor (4 Indent space is important when you create an if-else statement, for loop, function etc).
  • In VS code Terminal window, delete old terminal output by clicking the Trash icon.

About The Author

Scroll to Top