Working with Python in Visual Studio (Windows)

Python is a popular programming language that is reliable, flexible, easy to learn, free to use on all operating systems, and supported by both a strong developer community and many free libraries. Python supports all manners of development, including web applications, web services, desktop apps, scripting, and scientific computing and is used by many universities, scientists, casual developers, and professional developers alike. You can learn more about the language on python.org and Python for Beginners.

Visual Studio on Windows provides open-source support for the Python language through the Python development and Data Science workloads (Visual Studio 2017) and the free Python Tools for Visual Studio extension (Visual Studio 2015 and earlier). Python is not presently supported in Visual Studio for Mac, but is available on Mac and Linux through Visual Studio Code (see questions and answers).

To get started:

Feature Description General Visual Studio Documentation
Visual Studio project system Implicitly picks up a folder structure of Python code while allowing explicit control to identify app code, test code, web pages, JavaScript, build scripts, etc. Solutions and Projects in Visual Studio
Project templates Quickly creates project structure for console, web, Azure, data science, and other types of projects Visual Studio Templates
Multiple interpreter support Supports various versions of CPython and IronPython. n/a
IPython support Includes support for IPython/Jupyter in the REPL for inline plots, .NET, and Windows Presentation Foundation (WPF). n/a
Rich editing, IntelliSense, and code comprehension Includes syntax coloring, auto-complete across all your code and libraries, code formatting, signature help, class view, Go to Definition, Find All References, code snippets, refactoring, PyLint, and more. Writing Code in the Code and Text Editor
Interactive Window Provides a quick REPL experience for Python with the ability to easily highlight a portion of your code and send it to the Interactive Window. n/a
Full-featured debugging Debugging can be done with or without a Visual Studio project, including the ability to debug an existing executable, Python/C++ mixed-mode debugging, remote debugging on Linux to Windows/Linux/Mac, remote debugging on Azure, and debugging within the Interactive Window. Debugging in Visual Studio
Profiling tools with comprehensive reporting Explores how time is being spent within your application, including the ability to compare performance between different profiling runs. Profiling Tools (not all Visual Studio profiling features are available for Python)
Unit testing tools Discover, run, and manage tests in Visual Studio Test Explorer, and easily debug unit tests. Unit test your code

The Python workload also includes the Azure SDK for Python, which simplifies consuming Azure services from Windows, Mac OS X, and Linux apps.

movie camera icon for video Watch a video series (Microsoft Virtual Academy) for an introduction to Python in Visual Studio (22 minutes total).
movie camera icon for video Also see the following videos on Microsoft Virtual Academy:

Questions and answers

Q. Is Python support available with Visual Studio for Mac?

A. Not at this time, though it is requested on UserVoice. The Visual Studio for Mac documentation identifies the current types of development that it does support. In the meantime, Visual Studio Code on Windows, Mac, and Linux works well with Python through available extensions.

Q. What can I use to build UI with Python?

A. The main offering in this area is the Qt Project, with bindings for Python known as PySide (the official binding) (also see PySide downloads) and PyQt. At present, Python support in Visual Studio does not include any specific tools for UI development.

Q. Can a Python project produce a stand-alone executable?

A. Python is generally an interpreted language, with which code is run on demand in a suitable Python-capable environment such as Visual Studio and web servers. Visual Studio itself does not at present provide the means to create a stand-alone executable, which essentially means a program with an embedded Python interpreter. However, there are various means within the Python community to create executables as described on StackOverflow. CPython also supports being embedded within a native application, as described on the blog post, Using CPython's Embeddable Zip File.

Features matrix

Python features can be installed in the following editions of Visual Studio as described in the installation guide:

  • Visual Studio 2017 (all editions)
  • Visual Studio 2015 (all editions)
  • Visual Studio 2013 Community Edition
  • Visual Studio 2013 Express for Web, Update 2 or higher
  • Visual Studio 2013 Express for Desktop, Update 2 or higher
  • Visual Studio 2013 (Pro edition or higher)
  • Visual Studio 2012 (Pro edition or higher)
  • Visual Studio 2010 SP1 (Pro edition or higher; .NET 4.5 required)

Important

Features are fully supported and maintained for only the latest version of Visual Studio. Features are available in older versions but are not actively maintained.

Python Support 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Multiple interpreters management
Auto-detect popular interpreters
Add custom interpreters
Virtual Environments
Pip/Easy Install


Project System 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
New project from existing code
Show all files
Source control
Git integration 1


Editing 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Syntax highlighting
Auto-complete
Signature help
Quick info
Object browser/class view
Navigation bar
Go to Definition
Navigate to
Find All References
Auto indentation
Code formatting
Refactor - rename
Refactor - extract method
Refactor - add/remove import
PyLint


Interactive Window 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Interactive Window
IPython with inline graphs


Desktop 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Console/Windows application
IronPython WPF (with XAML designer)
IronPython Windows Forms


Web 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Django web project
Bottle web project
Flask web project
Generic web project


Azure 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Deploy to web site 2
Deploy to web role 4 4 3
Deploy to worker role ? ? ? 4 4 3
Run in Azure emulator ? ? ? 4 4 3
Remote debugging 6 8 8
Server Explorer attach 7 7


Django templates 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Debugging
Auto-complete 5 5
Auto-complete for CSS and JavaScript 5 5


Debugging 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Debugging
Debugging without a project
Debugging - attach to editing
Mixed-mode debugging
Remote debugging (Windows, Mac OS X, Linux)
Debug interactive window


Profiling 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Profiling


Test 2017 2015 2013 Comm 2013 Desktop 2013 Web 2013 Pro+ 2012 Pro+ 2010 SP1 Pro+
Test explorer
Run test
Debug test


  1. Git support for Visual Studio 2012 is available in the Visual Studio Tools for Git extension, available on the Visual Studio Gallery.

  2. Deployment to Azure Web Site requires Azure SDK for .NET 2.1 - Visual Studio 2010 SP1. Later versions don't support Visual Studio 2010.

  3. Support for Azure Web Role and Worker Role requires Azure SDK for .NET 2.3 - VS 2012 or later.

  4. Support for Azure Web Role and Worker Role requires Azure SDK for .NET 2.3 - VS 2013 or later.

  5. Django template editor in Visual Studio 2013 has some known issues that are resolved by installing Update 2.

  6. Requires Windows 8 or later. Visual Studio 2013 Express for Web doesn't have the Attach to Process dialog, but Azure Web Site remote debugging is still possible using the Attach Debugger (Python) command in Server Explorer. Remote debugging requires Azure SDK for .NET 2.3 - Visual Studio 2013 or later.

  7. Requires Windows 8 or later. Attach Debugger (Python) command in Server Explorer requires Azure SDK for .NET 2.3 - Visual Studio 2013 or later.

  8. Requires Windows 8 or later.

Additional resources