Now you know why VSCode is awesome, and why it’s probably the best choice for you too. You probably can’t wait to install VSCode, right? We’ll explore different ways of installing VSCode and how to start it.
Installing VSCode
Just like when installing Python, there are a number of ways to install VSCode.
Download from the official site
VSCode can be downloaded for free from this website. It’s available for the following platforms:
- Windows
- Linux
- macOS
Make sure you download the correct binary for your platform. The website tries to detect your platform automatically and offer the correct link, so that shouldn’t be too hard! After downloading, open the file and follow the steps to install it on your system.
On Windows, pick the User setup, which doesn’t need administrator rights. Leave the Add to PATH option checked during the installation, so you can start VSCode from the command line later on. On macOS, the download is a zip file containing the app. Drag Visual Studio Code.app to your Applications folder.
Use OS specific package manager
Package managers are a good alternative to downloading VSCode yourself. On Windows, you can use winget from a terminal:
winget install Microsoft.VisualStudioCode
On macOS, if you are a Homebrew user, you can install the vscode cask with:
$ brew install --cask visual-studio-code
If you’re on Ubuntu, you might want to use snap instead (sudo snap install code --classic). The official .deb and .rpm packages also add Microsoft’s repository to your system, so VSCode gets updated along with the rest of your packages. All these methods are fine, and probably even better than downloading VSCode manually. I personally use the snap packages on Ubuntu, and it works flawlessly and stays up-to-date with the latest releases.
VS Codium
Although VSCode is free, some people worry since it’s built and maintained by Microsoft. From what I understand, the code is open-source, but the binary builds are not. Microsoft takes the open-source and adds some extra’s, like branding and telemetry (you can turn this off).
If you are an open-source purist, there’s a binary distribution built by the community, called vscodium. I haven’t tried it myself but it should work completely the same as the official release. To be absolutely clear: VSCode itself is free. Personally, I’m fine with Microsoft building the binary and even don’t mind the telemetry that much, although I usually turn it off when installing a new OS.
Starting VSCode
There are two ways you can start VSCode:
- Looking it up in the menu and clicking it
- Starting it from the command-line
Starting VSCode from the start menu
Most operating systems have a menu system, e.g.:
- The start menu on Windows
- Spotlight on macOS (press Cmd+Space and type “code”)
- Similar functionality on Linux, e.g. in the Gnome Shell.
If you want to open up VSCode, simply look it up and click the icon.
Starting VSCode from the command-line
The big advantage of starting VSCode from the command line is that you can directly pass a path or file to open it. This needs the code command to be on your PATH:
- On Windows, the installer adds it if you left Add to PATH checked. Open a new terminal after installing, so it picks up the change.
- On macOS, start VSCode once, open the Command Palette with Cmd+Shift+P, type shell command and run the Shell Command: Install ‘code’ … in PATH command.
- On Linux, the snap, .deb and .rpm packages set it up for you.
Now you can open the current directory as a project in VSCode, simply by typing:
$ code .Code language: Bash (bash)
You can use the code command to open a specific file as well:
$ code myscript.pyCode language: Bash (bash)
Install the Python extension
VSCode doesn’t know much about Python out of the box. To get syntax checking, code completion, debugging and running your code with a single click, install Microsoft’s Python extension:
- Open the Extensions view by clicking the blocks icon in the sidebar, or with Ctrl+Shift+X (Cmd+Shift+X on macOS).
- Search for “Python” and install the extension published by Microsoft.
VSCode usually suggests this extension by itself the first time you open a .py file. Once it’s installed, open the Command Palette (Ctrl+Shift+P, or Cmd+Shift+P on macOS) and run Python: Select Interpreter to choose which Python installation or virtual environment VSCode should use for your project. If your project has a .venv folder, VSCode usually picks it automatically.
Next, learn how to run and debug Python in VSCode, or have a look at other useful VSCode extensions for Python.