Installing Visual Studio Code(VS Code) for Python 3
A step-by-step visual guide to installing VS Code IDE for Python.
If you are done with installing Python on your machine, it is time to download an Integrated Development Environment(IDE) to run your Python code and build cool applications.
Why should you use an IDE?
Although you can learn to code using the Python Interactive session on your command line, you should use an IDE for writing and organizing your code.
Why? Because an application is not a collection of arbitrary pieces of code, written here and there. It is a well-designed execution map of a process. An IDE allows you to group your code in order of functionality, create helpful documentation and build tests. It allows you to blend various aspects of software development.
In this article, you will learn to install Visual Studio Code(VS Code) for Windows 10. However, you can use this process for any operating system.
Step 1 - Download Visual Studio Code
Visit the website of Visual Studio Code. It will automatically show you the right
exe file for your operating system. Click on the “Download” button.
exe file will be downloaded and you will be redirected to a “Thank you for downloading VS Code” page.
Step 2 - Installing VS Code
Click on the downloaded
exe file and it should open up the installer.
Check “I accept the agreement” and click on “Next >”.
You can choose to create a Desktop icon and add VS Code to your PATH. Make the choices you want and press “Next >” and then press “Install”.
Once the installation finishes, you will see the successful installation page. When you click on “Finish”, VS Code Editor will be launched.
Step 3 - Write your first program
Open VS Code and click on “File” and then “Open Folder”. For the purpose of this tutorial, we will create our python files inside a
trial folder present in Desktop.
trial folder, create a new python file called
Write your first Python code
However, you won’t be able to run your code. You need to understand that VS Code works like a simple text editor. It has no built-in support for Python.
To run Python code, you need to download the Python extension for VS Code.
Step 4 - Download Python extension for VS Code
Click on the Extension button on the left-hand menu bar.
The Marketplace for VS Code Extensions should open up. Search for python in the search bar.
Choose the Python extension provided by Microsoft and click on “Install”. There are other Python extensions available, but I would recommend you to go with the official one.
Some of the features of the official VS Code extension for Python are:-
- Linting support with Flake8 or Pylint.
- Easy code debugging.
- IntelliSense support provides better code formatting and code navigation.
- Support for testing frameworks like Pytest or Unittest.
- Support for Jupyter Notebooks.
Now when you go back to your
test.py file, you should be able to see a Run button.
Once you click on the Run button, your Python code will be successfully executed.
Set up a Linter for VS Code
Linting is a process that analyzes code from any programming language and identifies problems like syntax errors, non-adherence to a prescribed coding style, or the use of unsafe constructs.
There are many linters available in VS Code. You might see a pop up in VS Code about not having a linter. Either you could directly install it from the pop up. By default, it will use Pylint. If you have installed the Python extension from Microsoft, Pylint should have been installed along with it.
But there are also other linters available in VS Code Extensions. My favorite ones are:-
You can search for these linters on the VS Code Extensions page.
Check out the installation guide for Pycharm.