How to Setup Python in Visual Studio Code on Windows 11

vote/تقييم

In this guide, we will discover: How to Setup Python in Visual Studio Code on Windows 11 – Easy Beginners Guide

We need a good text editor or IDE to code in any programming language. IDE stands for integrated Development Environment. It helps us to write and run the code. To code in Python, we need an advanced text editor or IDE. PyCharm and Visual Studio Code are popular editors used for Python. Here, we will discuss; how to set up Visual Studio Code for Python programming on Windows 11.

Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux, and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.

How to Setup Python in Visual Studio Code on Windows 11

To set up Visual Studio Code for Python programming on Windows 11. You need to install Python Interpreter and Visual Studio Code with the Python extension. First, let’s discuss the installation process of both these software.

If you prefer a video tutorial, you can watch the video mentioned below:

1. Install Python Interpreter

Python is a popular high-level and general-purpose programming language. It is used to build desktop GUIs, Web-based applications, websites, and many more. In addition, it is widely used in scientific computing, data analysis, and deep learning applications. Here are some reasons to learn Python programming.

Step 1: Visit python.org and click on “Downloads“. This will take you to the download page for Windows, here click on “Download Python 3.10.7” and wait for the download to complete.

Step 2: After the download has been completed open the installer file to install Python. Now on the set-up window, there you will find two installation options – “Install Now” and “Customize Installation“. Here click on the “Customize Installation” option, as we are going to install Python with pip and IDLE.

Note:- You can also go with the “Install Now” option for simple installation, and make sure to check the box called “Add Python 3.10. to PATH“. If Python is already installed add Python path to environment variables.

How to Install Python 1

Step 3: On the next window, select pip and tcl/tk and IDLE. After that, click on “Next”.

Note:- pip help you to download and install other Python packages and IDLE is the development environment for Python.

How to Install Python 2

Step 4: On the advanced options windows, here select the “Install for all users” option. This is helpful when you have multiple users on your Windows operating system. After that, click on the “Install“ button.

How to Install Python 3

Step 5: The installation will take some time, wait for the installation to complete. Once done click on the “Close” button.

2. Install Visual Studio Code and the Python Extension

Once you have downloaded and installed the Python interpreter on your device, you can follow the next steps. Now, you have to install Visual Studio Code along with the Python Extension. For that, follow the below-mentioned steps:

Step 1: Firstly, we need to download the installer file for the Windows operating system. For that, visit code.visualstudio.com and download the Windows version of Visual Studio Code.

Step 2: After you have downloaded the installer file, open it. A setup window will appear. Here, read the license agreement and accept the license agreement, then click on “Next” to continue.

Step 3: Now, select the installation location where you want to install Visual Studio Code. If you don’t have any good reason to change the installation location, then keep it to default and click on “Next” to continue.

Step 4: Here, give a name to the start menu folder. By default, it is ‘Visual Studio Code,‘ if you want, you can give another name and click on “Next” to continue. Also, you will find an option not to create a start menu folder at the bottom.

Step 5: In the next window, you will get an option to select additional tasks – like “create a desktop icon,” “Add to Path,” and more. Select the option you want to enable and then click on “Next” to continue.

Note:– It is very important to add Visual Studio Code to PATH. It requires restarting your system.

Step 6: Finally, you are ready to install the Visual Studio Code on Windows 11. Just review all your selections, then click on the “Install” button to begin the installation. It will take some time to install, so wait until the installation is complete.

Step 7: Open Visual Studio Code, click on the “Extensions” icon or use the shortcut key Ctrl + Shift +X. Now, search for the Python extension and click on the “Install” button. After installation is complete, reopen the Visual Studio Code to apply the change.

How to Create Python Project on Visual Studio Code

Once you have set up Python in Visual Studio Code, let’s discuss how we can create a Python project on Visual Studio Code. For that, follow the following steps:

Step 1: Click on the “Explorer” option, then click on the “Open Folder” button. Now, select the location; where you want to save the Python program or create a new folder for your Python project. 

Step 2: You will receive a pop-up “Do you trust the authors of the files in this folder?” Here, select “Trust the authors of all files in the parent folder,” then click on the “Yes, I trust the authors” button.

Step 3: To create a Python file, click on the “New File” icon. Then name your file with the .py extension and it will create a new python file.

Step 4: Now you are ready to write your Python program. To run your Python code, click the “Run” button, and you should get your output in the “Terminal” area.

Conclusion

That’s it; this is how you can set up Python in Visual Studio Code on Windows 11. Now, if you want to use Atom Editor for your Python programming, you can check out our detailed guide on; how to set up Atom Editor for Python on Windows 11.

I hope this article was helpful to you. If you liked the article, share it with your friends. If you have some suggestions, do not hesitate to leave them in the comments section. We will surely reply to you.

Leave a Comment