Installing Visual Studio Code(VS Code) for Python 3

A step-by-step visual guide to installing VS Code IDE for Python.

Installing Visual Studio Code(VS Code) for Python 3
Installing VS Code 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.

VS Code Homepage

Your exe file will be downloaded and you will be redirected to a “Thank you for downloading VS Code” page.

Downloading VS Code for Windows 10

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 >”.

VS Code Agreement page

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”.

Create a VS Code Desktop icon

Once the installation finishes, you will see the successful installation page. When you click on “Finish”, VS Code Editor will be launched.

VS Code Installation Success Page

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.

Open a folder to create a python file

In the trial folder, create a new python file called test.py.

Create a Python file called test.py

Write your first Python code print("Hello World!").

Your first code as a programmer - Hello World!

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.

Extension tool in VS Code

The Marketplace for VS Code Extensions should open up. Search for python in the search bar.

Download the Python extension provided by Microsoft

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.

Install Linter message from VS Code

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:-

  1. Black
  2. Autopep
  3. Flake8
  4. Yapf

You can search for these linters on the VS Code Extensions page.

Check out the installation guide for Pycharm.

Installing Pycharm Community Edition for Python 3
A step-by-step visual guide to installing Pycharm Community Edition for Python.

Subscribe to Pylenin

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe