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.
Double click on downloaded file and in
License Agreement window select "I accept the agreement" and click on "Next".
In Select Destination Location window click on Next.
In Select Start Menu Folder window click on Next.
In Select Additional Tasks window check
Create a desktop icon and click on Next.
In ready to install window click on "Install".
Wait for the installation to complete and click on
Finish.
Install Python Extension
Open the VSCode and click on Extensions.
Search for Python extension and click on
install.
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.
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.
Run the programme
Click om Terminal -> New Terminal and type
python hello_world.py
in the terminal and hit enter.
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 .