Python is one of the easiest programming languages and at the same time, it’s futuristic as it is used in Machine Learning, Data analysis, and more. One of the best IDEs for Python or programming in general is Microsoft’s Visual Studio Code. In this post, we will see how you can install Python in VS Code.
How to Install Python in VS Code
If you want to install Python in VS Code, follow the steps mentioned below.
- Download and install Python
- Install Visual Studio Code
- Create a Python file in VS Code
- Run Python
- Install Python Extension Package
Let us talk about them in detail.
1] Download and install Python
Our first job should be to download and install Python on our computer. Unlike C or C++, installing Python is pretty simple, all you have to do is go to python.org and click on the Download button. This will start downloading the Python installer. Once done, run the installer and follow the on-screen instructions to complete the installation process.
To confirm if Python is installed or not, we will check its version. To do the same, open Terminal, Command Prompt, or PowerShell and run the following command.
python --version
If you get a Python version as an output, you have successfully installed Python on your computer. In case, Python is not installed, go ahead and re-run the installation media we asked you to download earlier.
Read: Free Microsoft courses to learn AI, IoT, Data Science, and Machine Learning
2] Install Visual Studio Code
Now, go ahead and install Visual Studio Code on your computer. To do that, navigate to code.visualstudio.com and click on the Download for Windows icon. This will start downloading VS Code, you can just run the installer to install the application. Make sure to check all the right boxes during the installation process.
3] Create a Python file in VS Code
Once you have installed Python and VS Code IDE, all you need to do is create a Python file. To do that, open Visual Studio Code, go to File > New File, search for Python file, and click on it. This will generate a Python file. However, we would not recommend you go with this method, instead, create or select a folder first, then open that folder in VS Code, click on the New File button, and give it any name with a .py extension.
4] Run Python
After creating and opening the Python file, write a code and click on the Run button. This will execute the code and give you an output screen. If there is an error in your code, you will be notified.
5] Install the Python Extension Pack
Even though this step is optional, we recommend you download the Python Extension Pack. It is a must-have for someone who is serious about programming as apart from Python it includes the following things.
- Jinja template language support for Visual Studio Code.
- Beautiful syntax and scoped snippets for perfectionists with deadlines in Django.
- Visual Studio IntelliCode provides AI-assisted productivity features for Python developers in Visual Studio Code. It offers insights based on understanding your code combined with machine learning.
- Python Environment Manager lets you view and manage all of your Python environments and packages from a single place.
- Python Docstring Generator helps you quickly insert Python comment blocks with contextually inferred parameters for classes and methods based on multiple, selectable template patterns.
- Python Indent corrects Python indentation in Visual Studio Code.
- Jupyter provides Jupyter Notebook support for Python language. It’s used for data science, scientific computing, and machine learning.
To install it, go to Extensions, search for “Python Extension Package” and click on the Install button.
Read: How to open and view Python PY files on Windows
How can I install Python in VS Code?
You can download Python from their official website and run the installer to install it on your computer or in VS Code, go to Extensions, search for “Python” or “Python Extension Package” (Recommended), and install it. Now, you can write Python code and run it nonchalantly.
Read: How to install NumPy using PIP on Windows
How can I run Python on VS Code?
To run a Python code, select the line you want to run, and either click on the Run button or hit Shift + Enter. This will run the code and give you the required output at the bottom of the screen.
Also Read: How to uninstall Python PIP package and dependencies.