How to Set Up Visual Studio Code for Python
Creating and debugging programs in Python is easier when using a specialized Integrated Development Environment (IDE). With an IDE, you can quickly and efficiently develop, test, and debug programs.
Visual Studio Code (VS Code) for Python provides full support for the language and offers a wide range of plugins and extensions. In this article, we will install Visual Studio Code on three operating systems (Windows, macOS, Linux) and set it up for Python programming, including the use of popular plugins.
Prerequisites Copy link
To install and set up Visual Studio Code for Python, we will need the following:
-
A personal or work computer with Windows 10/11, macOS, or Ubuntu Linux distribution version 24.04 pre-installed. Alternatively, you can rent a dedicated server or a virtual machine with Windows Server 2016/2019/2022. If using regular versions of Windows, you can download your own ISO image in advance. You can also rent a server with Ubuntu.
Installing the Python Interpreter Copy link
Before installing VS Code, we need to install the Python interpreter on all three operating systems — Windows, macOS, and Linux.
On Windows Copy link
-
Go to the official Python website and download the installer file. In this case, we will be installing Python version 3.13.1.

- Run the installer file.
- You will have two installation options:
-
-
Install Now — This performs a full installation, including documentation files, the package manager pip, the tcl/tk library for graphical interface support, and standard libraries.
-
Customize Installation — This option allows you to choose which components to install.
-
We will use the full installation. Make sure to check the box next to the option Add python.exe to PATH and click Install Now. The installation process will begin.

-
Once the installation is complete, the program will notify you that it has finished.

On macOS Copy link
On macOS, the Python interpreter is pre-installed by default. You can verify this by running the following command in the terminal:
python3 --version
However, the installed version may be outdated. If necessary, you can install a newer version. To do this, we will use the Homebrew package manager. First, if Homebrew is not installed on your system, you can install it by running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Next, you need to check which versions of Python are available for installation. Use the following command:
brew search pythonIn our case, several versions of Python are available:

Install the latest available version, Python 3.13, by running the following command:
brew install python@3.13Check the Python version again:
python3 --version
python3.13 --version
As shown in the screenshot above, running the python3 --version still shows the old version (Python 3.9.6). However, the newly installed version (3.13) can be accessed using the command python3.13 --version. If needed, you can change the default Python version to the newly installed one. To do this, first get the full path to the newly installed Python interpreter using the following command:
brew --prefix python@3.13Then, check which shell you are using:
echo $SHELLDepending on the shell used, open the corresponding file for editing:
For bash or sh:
nano ~/.bashrcFor zsh:
nano ~/.zshrcAdd the following line at the end of the file:
export PATH="/opt/homebrew/opt/python@3.13/bin:$PATH"Save the changes and reload the file:
source ~/.zshrcNow, when you check the Python version, it will display the latest installed version:
python3 --version
On Ubuntu Copy link
By default, Python is pre-installed on almost all Linux distributions, including Ubuntu. In the latest supported versions of Ubuntu, the current version of Python is installed:
python3 --version
However, if Python is not installed for any reason, you can install it by running the following command:
apt -y install python3Installing Visual Studio Code Copy link
You can install Visual Studio Code on your personal computer. You can also rent a dedicated or cloud server with Windows Server or one of the available Linux distributions. If the required distribution is not available in the list of offered images, you can upload your own.
We will cover the installation of Visual Studio Code on three operating systems: Windows, macOS, and Linux (Ubuntu 24.04 distribution).
For Windows Copy link
Visual Studio Code supports installation on Windows 10 and Windows 11. It also supports Windows Server distributions, from version 2016 to 2022.
We will install it on Windows 10.
- Go to the official website and download the installer.

- This will download an
.exeinstallation file. Run the installer file. - On the first step, accept the license agreement by selecting the option "I accept the agreement".

- Next, the installer will prompt you to choose an installation location. You can choose the default path suggested by the installer or specify your own.

- If necessary, you can create a shortcut for the program in the Windows menu. If you don’t want to create a shortcut, select the option "Don’t create a Start Menu folder" at the bottom:

- The next step lets you configure additional options by ticking the corresponding checkboxes:
-
-
Create a desktop icon — creates a shortcut on the desktop for quick access to the program.
-
Add “Open with Code” action to Windows Explorer file context menu — adds the "Open with Code" option to the context menu when right-clicking on a file. This option allows you to quickly open any file directly in Visual Studio Code.
-
Add “Open with Code” action to Windows Explorer directory file context menu — similar to the above option but adds the "Open with Code" option to the context menu of directories (folders).
-
Register Code as an editor for supported file types — makes Visual Studio Code the default editor for certain file types (e.g., .c, .cpp, .py, .java, .js, .html files).
-
Add to PATH (require shell restart) — adds Visual Studio Code to the system’s PATH variable so it can be launched from the command line (cmd).
-

- Once all necessary options are set, Visual Studio Code is ready for installation. Click Install.
After the installation is complete, you can launch the program immediately:

For macOS Copy link
- Go to the official website and download the installer:

- After downloading, you will have a ZIP archive. Inside the archive, you will find the executable file, which you need to extract to the "Applications" directory.
- On the first launch, the system will notify you that this file was downloaded from the internet and may not have vulnerabilities. Click Open to continue:

For Linux (Ubuntu) Copy link
Visual Studio Code supports installation on Linux distributions such as Ubuntu, Debian, Red Hat, Fedora, and SUSE. You need a graphical desktop environment to install Visual Studio Code on Linux (GNOME, KDE, Xfce, etc.).
Let’s consider the installation of Visual Studio Code on Ubuntu 24.04 with the Xfce desktop environment. You can also install Visual Studio Code using Snapcraft.
-
Go to the official website and download the installer for your Linux distribution. In our case, we need the
.debinstaller:

-
Once the file is downloaded, open a terminal (console) and navigate to the directory where the file was downloaded (e.g.,
/root). -
To install, run the following command where
code_1.96.2-1734607745_amd64.debis the name of the downloaded file:
dpkg -i code_1.96.2-1734607745_amd64.deb-
During installation, a message will prompt you to add Microsoft repositories to the system. Select <Yes> and press Enter:

-
Wait for the installation to complete.
-
Once the installation is finished, you can launch the program from the applications menu (for distributions using Xfce, Visual Studio Code is available in the menu: Applications → Development):

Adding Python Interpreter to PATH Variable in Windows Copy link
If you haven't checked the Add python.exe to PATH checkbox during the Python installation on Windows, you need to manually add the full path to the interpreter to run Python from the command line.
To do this:
- Press Win+R, type
sysdm.cplin the Run window, and press Enter. - In the window that opens, go to the Advanced tab and click on the Environment Variables button.

- To add a user-level variable, select the Path variable under User variables and click on Edit.

- Double-click on an empty field or click the New button.
- Enter the full path to the Python interpreter file. By default, the Python interpreter is located at the following path:
C:\Users\<Username>\AppData\Local\Programs\Python\Python313For example:
C:\Users\Administrator\AppData\Local\Programs\Python\Python313
- After entering the path, click OK to save the changes.
- To verify, open the command prompt and type
python. If the path to the interpreter is correctly specified, the Python console will open.

Setting Up Python Interpreter in Visual Studio Code Copy link
In Windows Copy link
Once Python is installed, you need to connect it to Visual Studio Code. To do this:
-
Open Visual Studio Code and click the New File... button on the home page to create a new file.

Alternatively, you can create a Python project in Visual Studio Code by clicking on Open Folder…, where you can select the entire project folder containing the files.
-
Type any name for the file, use the
.pyextension, and press Enter.

-
Save the file in any location. Ensure that the file name ends with the
.pyextension.

- Once the file is saved, the interface in Visual Studio Code will display a prompt at the bottom right, suggesting you install the recommended Python extension.

- To run Python in Visual Studio Code, you first need to select the Python interpreter. A button will appear at the bottom of the panel with a warning: Select Interpreter. Click on it.

- In the menu that appears, select Enter interpreter path… and press Enter.

- Specify the full path to the Python interpreter. By default, it is located at:
C:\Users\Administrator\AppData\Local\Programs\Python\Python313where Administrator is your user account name. Select the file named python and click on Select Interpreter.

To test it, write a simple program that calculates the square root of a number:
import math
num = float(input("Enter a number to find its square root: "))
if num >= 0:
sqrt_result = math.sqrt(num)
print(f"The square root of {num} is {sqrt_result}")
else:
print("Square root of a negative number is not real.")
In Visual Studio Code, to run the Python code, click the Run Python File button at the top-right. If the interpreter is set up correctly, the program will run successfully.

In macOS Copy link
On macOS operating systems, the Python interpreter is automatically recognized. Simply create a new .py file as described in the Windows section above and run the program directly.

In Ubuntu Copy link
Similarly to macOS, in the Ubuntu distribution, VS Code automatically detects the installed Python interpreter in the system. All you need to do is create a new .py file and run the program directly.

Recommended Extensions for Python in Visual Studio Code Copy link
VS Code offers a wide range of Python extensions (plugins) that simplify the development process. Here are some of the most popular ones:
Pylance
Pylance provides code analysis, autocompletion, and IntelliSense support, making Python development more efficient and user-friendly. Key features include fast autocompletion, type checking, and IntelliSense support.

Jupyter
The Jupyter extension is a powerful tool for working with interactive notebooks directly in the editor. It’s especially useful for data analysis, machine learning, visualization, and interactive programming tasks.

autoDocstring — Python Docstring Generator
autoDocstring is a popular extension that helps automatically generate docstrings for Python functions, methods, and classes. Docstrings improve code readability and serve as built-in documentation.

isort
isort is a tool for automatically sorting and organizing imports in Python code. You can configure it in Visual Studio Code to make working with imports easier and to improve code readability.

Conclusion Copy link
This article covered the installation and setup of Visual Studio Code for Python development. Visual Studio Code offers full support for Python and provides the ability to extend its functionality through various plugins, making the coding process easier and more efficient.