How to install Python back up in Visual Studio on Windows

To install Python back up for Visual Studio (also known as Python Tools for Visual Studio or PTVS), follow the instructions in the department that matches your version of Visual Studio:

  • Visual Studio 2022
  • Visual Studio 2022
  • Visual Studio 2022
  • Visual Studio 2022 and earlier

To apace test Python support after post-obit the installation steps, open the Python Interactive window by pressing Alt+I and entering two+2. If you don't come across the output of iv, recheck your steps.

Tip

The Python workload includes the helpful Cookiecutter extension that provides a graphical user interface to detect templates, input template options, and create projects and files. For details, see Utilise Cookiecutter.

Note

Python support isn't presently available in Visual Studio for Mac, just is bachelor on Mac and Linux through Visual Studio Code. Encounter questions and answers.

Visual Studio 2022

Visual Studio 2022

Visual Studio 2022

  1. Download and run the latest Visual Studio installer. If you have Visual Studio installed already, run the Visual Studio Installer, select the Change option (see Modify Visual Studio) and get to step 2.

  2. The Visual Studio installer provides yous a listing of workloads that are groups of related options for specific development areas. For Python, select the Python evolution workload.

    Optional: if you're working with data science, too consider the Information science and belittling applications workload. This workload includes back up for the Python, R, and F# languages. For more information, run into Data scientific discipline and belittling applications workload.

    Python development workload in the Visual Studio installer.

  3. On the right side of the installer, choose other options if you want. Skip this step to accept the default options.

    Python development options in the Visual Studio 2022 installer

    Python development options in the Visual Studio 2022 installer

    Python development options in Visual Studio 2022 installer

Option Description
Python distributions Choose any combination of the available options, such every bit 32-bit and 64-chip variants of the Python 2, Python 3, Miniconda, Anaconda2, and Anaconda3 distributions that yous program to work with. Each includes the distribution's interpreter, runtime, and libraries. Anaconda, specifically, is an open data science platform that includes a broad range of pre-installed packages. (Yous tin return to the Visual Studio installer at any time to add or remove distributions.) Note: If you've installed a distribution outside of the Visual Studio installer, there'southward no need to check the equivalent option here. Visual Studio automatically detects existing Python installations. Run into The Python Environments window. Also, if a newer version of Python is available than what'south shown in the installer, yous tin install that version separately and Visual Studio volition detect it.
Cookiecutter template support Installs the Cookiecutter graphical UI to discover templates, input template options, and create projects and files. Meet Use the Cookiecutter extension.
Python web support Installs tools for web development including HTML, CSS, and JavaScript editing back up, forth with templates for projects using the Bottle, Flask, and Django frameworks. See Python web project templates.
Python native development tools Installs the C++ compiler and other necessary components to develop native extensions for Python. Encounter Create a C++ extension for Python. Also install the Desktop development with C++ workload for full C++ support.

After installation, the installer provides options to modify, launch, repair, or uninstall Visual Studio. The Change button changes to Update when updates to Visual Studio are available for any installed components. (The Modify choice is then available on the drop-downward menu.) You can also launch Visual Studio and the installer from the Windows Starting time menu by searching on "Visual Studio".

Launching, modifying, modifying, or uninstalling Visual Studio from the installer-2022

Launching, modifying, modifying, or uninstalling Visual Studio from the installer-2019

Note

The Python and Data Science workloads are available simply with Visual Studio 2022 version fifteen.ii and after.

Troubleshooting

To ready issues while installing or running Python in Visual Studio, try the following steps:

  • Determine whether the same error occurs using the Python CLI, that is, running python.exe from a command prompt.
  • Use the Repair option in the Visual Studio installer.
  • Repair or reinstall Python through Settings > Apps & features in Windows.

Example mistake: Failed to start interactive process: System.ComponentModel.Win32Exception (0x80004005): Unknown error (0xc0000135) at Microsoft.PythonTools.Repl.PythonInteractiveEvaluator.d__43.MoveNext().

Visual Studio 2022

  1. Run the Visual Studio installer through Control Panel > Programs and Features, selecting Microsoft Visual Studio 2022 and and so Alter.

  2. In the installer, select Alter.

  3. Select Programming Languages > Python Tools for Visual Studio and so Next:

    PTVS option in Visual Studio 2022 installer

  4. Once Visual Studio setup is consummate, install a Python interpreter of your pick. Visual Studio 2022 supports only Python 3.5 and earlier; afterwards versions generate a bulletin like Unsupported Python version three.6). If you already have an interpreter installed and Visual Studio doesn't detect it automatically, see Manually identify an existing surround.

Visual Studio 2022 and before

  1. Install the appropriate version of Python Tools for Visual Studio for your version of Visual Studio:

    • Visual Studio 2022: PTVS ii.two.2 for Visual Studio 2022. The File > New Project dialog in Visual Studio 2022 gives you a shortcut for this procedure.
    • Visual Studio 2022 and 2022: PTVS 2.ane.1 for Visual Studio 2022 and 2022
  2. Install a Python interpreter of your pick. If you already have an interpreter installed and Visual Studio doesn't detect information technology automatically, see Manually place an existing environment.

Install locations

By default, the Python support installs for all users on a computer.

For Visual Studio 2022, the Python workload installs in %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.

By default, the Python support installs for all users on a computer.

For Visual Studio 2022 and Visual Studio 2022, the Python workload installs in %ProgramFiles(x86)%\Microsoft Visual Studio\<VS_version>\<VS_edition>Common7\IDE\Extensions\Microsoft\Python where <VS_version> is 2022 or 2022 and <VS_edition> is Community, Professional, or Enterprise.

For Visual Studio 2022 and earlier, installation paths are as follows:

  • 32-bit:
    • Path: %Program Files(x86)%\Microsoft Visual Studio <VS_ver>\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\<PTVS_ver>
    • Registry location of path: HKEY_LOCAL_MACHINE\Software\Microsoft\PythonTools\<VS_ver>\InstallDir
  • 64-bit:
    • Path: %Program Files%\Microsoft Visual Studio <VS_ver>\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\<PTVS_ver>
    • Registry location of path: HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\PythonTools\<VS_ver>\InstallDir

Where:

  • <VS_ver> is:
    • 14.0 for Visual Studio 2022
    • 12.0 for Visual Studio 2022
    • 11.0 for Visual Studio 2022
    • 10.0 for Visual Studio 2022
  • <PTVS_ver> is a version number, such as two.2.two, 2.i.1, 2.0, 1.v, 1.1, or 1.0.

User-specific installations (ane.5 and earlier)

Python Tools for Visual Studio i.v and earlier immune installation for the current user only, in which case, the installation path is %LocalAppData%\Microsoft\VisualStudio\<VS_ver>\Extensions\Microsoft\Python Tools for Visual Studio\<PTVS_ver> where <VS_ver> and <PTVS_ver> are the same as described in a higher place.