How do I set up visual studio code with Python?

FAQs

Requirements

Install Visual Studio Code available here: Install VS Code.
Download and install Python on your PC: Install Python.

Create your python project

Open Visual Studio code and then click on open folder to create a new folder for your project:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-open-vs-code.png

Create a new folder:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-create-new-folder.png

Select the folder:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-select-folder.png

The new project opens up on VS Code:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-new-project.png

Make sure you have the python extension for VS Code installed:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-python-extension.png

Set up your environment variables

1. To set up workspace settings for Python.

Go to File > Preferences > Settings.
Select Workspace Settings and in the Search bar enter the key word pythonpath:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-python-workspace-settings.png

Copy the path to the python.exe file installed on your PC:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-path-pythonexe.png

Paste the path in the Python Path setting, highlighted below:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-config-python.png

2. To set up environment variables for pip3.

Right click on This PC > Properties > Advanced system settings > Environment Variables.

Edit the environment variable ‘path’:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-pip3-environment-variables.png

Browse to the directory where the pip3 exe file is available. pip3 is usually found inside the Scripts folder (under the same directory of python.exe).

Select OK to add the path to the environment variable:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-pip3-environment-variables-continued.png

Now we have set up the required environment variables.

Create a new file

Click on the file icon to create a new file. Give the file a name ending with the extension “.py” (stands for python):

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-create-new-file.png

You are now ready to code your new program:

files/pages/support/faqs/bb-400-faqs/how-do-i-set-up-visual-studio-code-with-python-setup-complete.png


FAQs