Python build tools windows

How to install Python support in Visual Studio on Windows

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:

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.

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.

Python support is not presently available in Visual Studio for Mac, but is available on Mac and Linux through Visual Studio Code. See questions and answers.

Visual Studio 2019 and Visual Studio 2017

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

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

The installer presents you with a list of workloads, which are groups of related options for specific development areas. For Python, select the Python development workload.

Optional: if you’re working with data science, also consider the Data science and analytical applications workload. This workload includes support for the Python, R, and F# languages. For more information, see Data science and analytical applications workload.

The Python and Data Science workloads are available only with Visual Studio 2017 version 15.2 and later.

Optional: if you’re working with data science, also consider the Data science and analytical applications workload. This workload includes support for the Python and F# languages. For more information, see Data science and analytical applications workload.

On the right side of the installer, chose additional options if desired. Skip this step to accept the default options.

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 IoT support Supports Windows IoT Core development using Python.
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.
Azure Cloud Services core tools Provides additional support for developer Azure Cloud Services in Python. See Azure cloud service projects.
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.
Azure Cloud Services core tools Provides additional support for developer Azure Cloud Services in Python. See Azure cloud service projects.

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».

Troubleshooting

If you encounter problems installing or running Python in Visual Studio, try the following:

  • 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().

Visual Studio 2015

Run the Visual Studio installer through Control Panel > Programs and Features, selecting Microsoft Visual Studio 2015 and then Change.

In the installer, select Modify.

Select Programming Languages > Python Tools for Visual Studio and then Next:

Once Visual Studio setup is complete, install a Python interpreter of your choice. Visual Studio 2015 supports only Python 3.5 and earlier; later versions generate a message like Unsupported Python version 3.6). If you already have an interpreter installed and Visual Studio doesn’t detect it automatically, see Manually identify an existing environment.

Visual Studio 2013 and earlier

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

  • Visual Studio 2013: PTVS 2.2.2 for Visual Studio 2013. The File >New Project dialog in Visual Studio 2013 gives you a shortcut for this process.
  • Visual Studio 2010 and 2012: PTVS 2.1.1 for Visual Studio 2010 and 2012

Install a Python interpreter of your choice. If you already have an interpreter installed and Visual Studio doesn’t detect it automatically, see Manually identify an existing environment.

Install locations

By default, Python support is installed for all users on a computer.

For Visual Studio 2019 and Visual Studio 2017, the Python workload is installed in %ProgramFiles(x86)%\Microsoft Visual Studio\ \ Common7\IDE\Extensions\Microsoft\Python where is 2019 or 2017 and is Community, Professional, or Enterprise.

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

    32-bit:

      Path: %Program Files(x86)%\Microsoft Visual Studio \Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\
  • Registry location of path: HKEY_LOCAL_MACHINE\Software\Microsoft\PythonTools\ \InstallDir
  • 64-bit:
    • Path: %Program Files%\Microsoft Visual Studio \Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\
    • Registry location of path: HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\PythonTools\ \InstallDir
    • is:
      • 14.0 for Visual Studio 2015
      • 12.0 for Visual Studio 2013
      • 11.0 for Visual Studio 2012
      • 10.0 for Visual Studio 2010

      is a version number, such as 2.2.2, 2.1.1, 2.0, 1.5, 1.1, or 1.0.

    User-specific installations (1.5 and earlier)

    Python Tools for Visual Studio 1.5 and earlier allowed installation for the current user only, in which case the installation path is %LocalAppData%\Microsoft\VisualStudio\ \Extensions\Microsoft\Python Tools for Visual Studio\

    Python build tools windows

    On Windows? Want to compile native Node modules? Install the build tools with this one-liner. Start PowerShell as Administrator and run:

    Or, if you are using Yarn:

    After installation, npm will automatically execute this module, which downloads and installs Visual C++ Build Tools, provided free of charge for most users by Microsoft (as part of Visual Studio Community, please consult the license to determine whether or not you’re eligible). These tools are required to compile popular native modules. If not already installed, it will also install Python 2.7, configuring your machine and npm appropriately.

    рџ’Ў [Windows Vista / 7 only] requires .NET Framework 4.5.1 (Currently not installed automatically by this package)

    Both installations are conflict-free, meaning that they do not mess with existing installations of Visual Studio, C++ Build Tools, or Python. If you see anything that indicates otherwise, please file a bug.

    Visual Studio 2017 vs Visual Studio 2015

    This module is capable of installing either the build tools from Visual Studio 2017 or Visual Studio 2015.

    By default, this tool will install the 2017 build tools. To change that, run this script with the —vs2015 parameter.

    • —offline-installers : Path to a folder with already downloaded installers. See
    • —python-mirror : Use a given mirror to download Python (like —python_mirror=https://npm.taobao.org/mirrors/python/ ). You can alternatively set a PYTHON_MIRROR environment variable.
    • —proxy : Use a given proxy. You can alternatively set a PROXY environment variable.
    • —debug : Be extra verbose in the logger output. Equal to setting the environment variable DEBUG to * .
    • —strict-ssl : Enables «Strict SSL» mode. Defaults to false.
    • —resume : By default, windows-build-tools will resume aborted downloads. Set to false to disable.
    • —sockets : Specifies the number of http sockets to use at once (this controls concurrency). Defaults to infinity.
    • —vcc-build-tools-parameters : Specifies additional parameters for the Visual C++ Build Tools 2015. See below for more detailed usage instructions.
    • —silent : The script will not output any information.
    • —vs2015 : Install the Visual Studio 2015 Build Tools instead of the Visual Studio 2017 ones.
    • —dry-run-only : Don’t actually do anything, just print what the script would have done.
    • —include-arm64-tools : Include the optional Visual Studio components required to build binaries for ARM64 Windows. Only available with the 2017 and newer build tools and Node.js v12 and up.

    Supplying Parameters to the VCC Build Tools

    You can pass additional parameters directly to the VCC Build Tools installer. This tool does not check if the parameters make sense — passing incorrect parameters might break the whole installation.

    Supply parameters to windows-build-tools as a JSON array. Here’s quick example (note the double quotes):

    Visual Studio 2015 Parameters

    If you run windows-build-tools with —vs2015 , these parameters are available:

    • /AdminFile : Specifies the installation control file.
    • /CreateAdminFile : Specifies the location to create a control file that can then be used
    • /CustomInstallPath :

    Set Custom install location.

  • /ForceRestart : Always restart the system after installation.
  • /Full : Install all product features.
  • /InstallSelectableItems : Choose which selectable item(s) to be installed. -selectable item to be installed, just pass in this switch without any value.
  • /Layout : Create a copy of the media in specified folder.
  • /NoRefresh : Prevent setup checking for updates from the internet.
  • /NoRestart : Do not restart during or after installation.
  • /NoWeb : Prevent setup downloading from the internet.
  • /Passive : Display progress but do not wait for user input.
  • /ProductKey : Set custom product key (no dashes).
  • /PromptRestart : Prompt the user before restarting the system.
  • /Repair : Repair the product.
  • /Uninstall : Uninstall the product.
  • /Uninstall /Force : Uninstall the product and features shared with other products.
  • Visual Studio 2017 Parameters

    The available parameters are documented here.

    By default, windows-build-tools will download the latest installers from Microsoft each time it’s installed. Alternatively, you can prepare a folder that contains installers. They need to have their original names:

    • Visual Studio Build Tools: vs_BuildTools.exe or BuildTools_Full.exe
    • Python: python-2.7.15.amd64.msi or python-2.7.15.msi

    Then, run windows-build-tools with the —offline-installers argument:

    This package currently only handles the most common use case, none of the edge cases. If you encounter errors, we’d greatly appreciate error reports (and even pull requests). This is currently tested on Windows 10.

    • windows-build-tools 4.0 and up require at least Node v8.
    • windows-build-tools 3.0 and up require at least Node v6.
    • windows-build-tools 1.0 and up require at least Node v4.

    Where is Python installed?

    It’s saved under %USERPROFILE%\.windows-build-tools\python27 .

    Installing as a Non-Administrator

    windows-build-tools works best if installed from an account with administrative rights. However, thanks to @brucejo75, the following steps can be taken to install to a different user account:

    1. From your non-admin account (e.g. ) run cmd.exe as administrator.
    2. Set the following environment variables in the new command shell:

    Ensure that the variables passed match your location of npm’s roaming data and the location of user profiles on your machine. For , substitute the name of the account you want to install windows-build-tools for. For more information, see the npm config set prefix description here.

    1. Run npm install -g windows-build-tools

    Examples of Modules Supported

    In theory, windows-build-tools supports all pure C++ addons for Node.js (and virtually everything else that requires a native compiler toolchain to be installed on your machine).

    To ensure that that’s true, we take a fresh Windows 10 installation, add windows-build-tools , and ensure that the most popular native Node addons compile from source. Those are: node-sass, bcrypt, sqlite3, serialport, websocket, deasync, grpc, canvas, sharp, hiredis, leveldown, nodegit, zqm, ffi, libxmljs, iconv, ref, sleep, microtime, couchbase, bignum, kerberos, and ursa.

    The Python installation was made possible by Ali Hajimirza, who kindly wrestled with Python’s MSIs until they surrendered. For details regarding the license agreements applicable to Python, see History and License 2.x and 3.x.

    Use of Microsoft software is subject to the terms of the corresponding license agreements. For details regarding the license agreements applicable to Visual Studio products, refer to their License Directory page. (See also this discussion for the gist of it.)

    Copyright (C) 2018 Felix Rieseberg. Licensed MIT. For more details, please see LICENSE. This license applies to this package only, not to its dependencies or the 3rd party software that it installs.

    Читайте также:  Подвисает мышь при движении windows
    Оцените статью