ערוך

שתף באמצעות


Install Python support in Visual Studio

Python support is available only on Visual Studio for Windows. On Mac and Linux, Python support is available through Visual Studio Code.

Prerequisites

Note

You also need a Python interpreter installed in order to work with Python in Visual Studio. We recommend installing one from python.org or Anaconda. For more information on Python interpreters, see Installing Python Interpreters.

Download and install the Python workload

Complete the following steps to download and install the Python workload.

  1. Download and run the latest Visual Studio Installer for Windows. Python support is present in release 15.2 and later. If you have Visual Studio installed already, open Visual Studio and run the installer by selecting Tools > Get Tools and Features.

    Tip

    The Community edition is for individual developers, classroom learning, academic research, and open source development. For other uses, install Visual Studio Professional or Visual Studio Enterprise.

  2. The installer provides a list of workloads that are groups of related options for specific development areas. For Python, select the Python development workload and select Install:

    Screenshot of the Python development workload selected in the Visual Studio installer.

    Python installation options Description
    Python distributions Choose any combination of Python distribution that you plan to work with. Common options include 32-bit and 64-bit variants of Python 2, Python 3, Miniconda, Anaconda 2, and Anaconda 3. Each option includes the distribution's interpreter, runtime, and libraries. Anaconda, specifically, is an open data science platform that includes a wide range of preinstalled packages. Visual Studio automatically detects existing Python installations. For more information, see The Python Environments window. Also, if a newer version of Python is available than the version shown in the installer, you can install the new version separately and Visual Studio detects it.
    Cookiecutter template support Install the Cookiecutter graphical UI to discover templates, input template options, and create projects and files. For more information, see Use the Cookiecutter extension.
    Python web support Install tools for web development including HTML, CSS, and JavaScript editing support, along with templates for projects using the Bottle, Flask, and Django frameworks. For more information, see Python web project templates.
    Python native development tools Install the C++ compiler and other necessary components to develop native extensions for Python. For more information, see Create a C++ extension for Python. Also install the Desktop development with C++ workload for full C++ support.

    By default, the Python workload installs for all users on a computer under:

    %ProgramFiles%\Microsoft Visual Studio\<VS_version>\<VS_edition>Common7\IDE\Extensions\Microsoft\Python

    where <VS_version> is 2022 and <VS_edition> is Community, Professional, or Enterprise.

    %ProgramFiles(x86)%\Microsoft Visual Studio\<VS_version>\<VS_edition>Common7\IDE\Extensions\Microsoft\Python

    where <VS_version> is 2019 or 2017 and <VS_edition> is Community, Professional, or Enterprise.

Test your install

Quickly check your installation of Python support:

  1. Launch Visual Studio.

  2. Select Alt + I to open the Python Interactive window.

  3. In the window, enter the statement 2+2.

    The statement output 4 displays in the window. If you don't see the correct output, recheck your steps.