Python | Setting up VScode

In the previous post we learned about Virtual environments in Python. In this post we will learn how to set up VSCode for Python. VSCode is very popular, lightweight and highly customizable. Let's follow below steps to setup VScode from scratch.

VSCode Installation

  • Navigate to here and download VScode executable for windows.
  • vscode setup python

  • Double click on downloaded file and in License Agreement window select "I accept the agreement" and click on "Next".
  • vscode setup python

  • In Select Destination Location window click on Next.
  • vscode setup python

  • In Select Start Menu Folder window click on Next.
  • vscode setup python

  • In Select Additional Tasks window check Create a desktop icon and click on Next.
  • vscode setup python

  • In ready to install window click on "Install".
  • Wait for the installation to complete and click on Finish.
  • vscode setup python

    vscode setup python


    Install Python Extension

  • Open the VSCode and click on Extensions.
  • vscode setup python

  • Search for Python extension and click on install.
  • vscode setup python


    Create New Python File

  • Click on File->New File and select Python file.
  • Save the file as hello_world.py.
  • Type print("hello world") in the file and save it.
  • vscode setup python


    Select Interpreter

  • Press Ctrl + Shift + P, and type Python: Select Interpreter in the prompt.
  • Select the Python Interpreter. You can choose the base interpreter or can navigate to the interpreter created in previous article.
  • vscode setup python


    Run the programme

  • Click om Terminal -> New Terminal and type python hello_world.py in the terminal and hit enter.
  • vscode setup python

    After running this script you should see hello world printed in the terminal. Now we have VSCode installed, let's create a directory where we will keep all our Python files for the next tutorials.

  • Create directory with name python-with-gcptutorials and open the directory with VScode using below commands.
  •    
    mkdir python-with-gcptutorials
    
    cd python-with-gcptutorials
    
    code .
    
       

    vscode setup python