Set up VS Code for Python
15 min · Beginner
Need help? Ask a tutor on WhatsApp (opens in a new tab)Visual Studio Code is a lightweight, powerful code editor. With the official Python extension from Microsoft, you get auto-complete, error detection and a one-click Run button.
Install Visual Studio Code
A code editor is a program for writing and running code. Visual Studio Code (VS Code) is a free one that works on Windows, macOS and Linux.
Download VS Code from code.visualstudio.com. It is free, works on Windows, macOS and Linux, and is the industry standard editor for Python development.
- Go to
code.visualstudio.comand click Download. - Run the installer using default settings.
- Open Visual Studio Code.
Install the Python extension
VS Code needs an extension to understand Python syntax, provide code completions, and run files.
- In VS Code, click the Extensions icon on the left bar (or press
Ctrl+Shift+Xon Windows,Cmd+Shift+Xon Mac). - Type
Pythonin the search box. - Find the extension named Python by Microsoft and click Install.
Create a workspace folder
A workspace folder is the one folder where you keep all files of a project, so VS Code can open and run them together.
Always keep your Python projects inside a dedicated workspace folder.
- In VS Code, click File → Open Folder.
- Create a new folder such as
python-practiceand open it. - Click the New File icon and name it
test.py.
Example
# test.pyprint("VS Code Ready")VS Code Ready
What this code does
- Create a file named test.py inside your project folder.
- Click the Play run button in the top right editor corner.
- The integrated terminal opens at the bottom and displays the output.
Next step
Check your understanding
5 quick questions