visualstudio-docs/installing-python-support-in-visual-studio.md at main · MicrosoftDocs/visualstudio-docs

title
description
ms.date
ms.custom
ms.topic
author
ms.author
manager
ms.technology
ms.workload

Install Python support

How to install the Python Tools for Visual Studio (PTVS) in Visual Studio 2017, 2015, 2013, 2012, and 2010, including options and installation locations.

12/11/2021

devdivchpfy22

how-to

cwebster-99

cowebster

jmartens

vs-python

python

data-science

How to install Python support in Visual Studio on Windows

[!INCLUDE Visual Studio]

To install Python support for Visual Studio (also known as Python Tools for Visual Studio or PTVS), follow the instructions in the section that matches your version of Visual Studio:
:::moniker range=”>=vs-2022″

-Visual Studio 2022
:::moniker-end
:::moniker range=”vs-2019″

To quickly test Python support after following the installation steps, open the Python Interactive window by pressing Alt+I and entering 2+2. If you don’t see the output of 4, recheck your steps.

[!Tip]
The Python workload includes the helpful Cookiecutter extension that provides a graphical user interface to discover templates, input template options, and create projects and files. For details, see Use Cookiecutter.

[!Note]
Python support isn’t presently available in Visual Studio for Mac, but is available on Mac and Linux through Visual Studio Code. See questions and answers.

:::moniker range=”>=vs-2022″

Visual Studio 2022

:::moniker-end
:::Moniker range=”vs-2019″

Visual Studio 2019

:::moniker-end

Option
Description

Python distributions
Choose any combination of the available options, such as 32-bit and 64-bit variants of the Python 2, Python 3, Miniconda, Anaconda2, and Anaconda3 distributions that you plan to work with. Each includes the distribution’s interpreter, runtime, and libraries. Anaconda, specifically, is an open data science platform that includes a wide range of pre-installed packages. (You can 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’s no need to check the equivalent option here. Visual Studio automatically detects existing Python installations. See The Python Environments window. Also, if a newer version of Python is available than what’s shown in the installer, you can install that version separately and Visual Studio will detect it.

Cookiecutter template support
Installs the Cookiecutter graphical UI to discover templates, input template options, and create projects and files. See Use the Cookiecutter extension.

Python web support
Installs tools for web development including HTML, CSS, and JavaScript editing support, along 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. See 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 Modify button changes to Update when updates to Visual Studio are available for any installed components. (The Modify option is then available on the drop-down menu.) You can also launch Visual Studio and the installer from the Windows Start menu by searching on “Visual Studio”.

:::moniker range=”>=vs-2022″

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

:::moniker-end
:::moniker range=”vs-2019″

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

:::moniker-end

Troubleshooting

To fix problems 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 error: Failed to start interactive process: System.ComponentModel.Win32Exception (0x80004005): Unknown error (0xc0000135) at Microsoft.PythonTools.Repl.PythonInteractiveEvaluator.d__43.MoveNext().

Install locations

:::moniker range=”>=vs-2022″

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.

:::moniker-end
:::moniker range=”<=vs-2019″

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

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

:::moniker-end