Open In App

Run Python File In Vscode

Last Updated : 05 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
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.

Run Python Script 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 (you can press Ctrl+Shift+X), and search for “Python.” Install the one provided by Microsoft, which is the official Python extension.

Screenshot2024-01-26203254-ezgifcom-resize

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:

Python3




print("Hello GeeksforGeeks")


Output:

Screenshot-2024-01-26-203648

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.

ezgifcom-crop

Step 5: Run the Python File

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

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

Using Specifiying 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.

ezgifcom-resize

Output in Terminal

Screenshot-2024-01-26-204512



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads