Open In App

Run Python File In Vscode

Last Updated : 12 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Visual Studio Code (VSCode) is a popular and versatile code editor that supports Python development with various features and extensions. In this article, we will see how to run Python files in VsCode.

Below is the step-by-step procedure by which we can run the basic Python Script in VScode:

Step 1: Installation

Install the following libraries before starting.

Step 2: Install Python Extension

Launch VSCode, go to the Extensions view (w can press Ctrl+Shift+X), and search for "Python." Install the one provided by Microsoft, which is the official Python extension.

pythonExtension

Step 3: Create a Python File

Create a new Python file or open an existing one. For example, let's create a file named basic.py with the following content:

Python
print("Hello GeeksforGeeks")

Output:

pythonFile

Step 4: Select Python Interpreter

In the bottom-right corner of the VSCode window, click on the interpreter version (it might say "Select Python Interpreter"). Choose the Python interpreter you want to use for this project.

pythonInterpreter

Step 5: Run the Python File

1. Using Right Click

Right-click on the editor or use the run button provided on thhe left corner of VScode to run the Python file. You should see the output in the terminal at the bottom of the VSCode window.

Screenshot2024-01-26204429-ezgifcom-png-to-webp-converter

2. Using Play Button

We can run our Python program inside the Python file using the Play button given on the right of the Visual Studio Code as given in the below picture.

Screenshot-2024-02-03-194202

3. Using Specifying the Path in the Terminal

We can also run the Python file by specifying the path in the terminal as shown in the below picture.

specifyingPathToRun
Specifying the Path to Run Python File

Output in Terminal

output


Next Article

Similar Reads