Using Python Tools for Visual Studio

Microsoft has traditionally shown limited support for most open-source languages. The IronPython project was one of the first to crack open the door, making it possible for other languages like PHP and Ruby to sneak in as well. While IronPython and IronRuby have diminished somewhat, there is a new project that has taken up the open-source mantle.

Python Tools for Visual Studio (PTVS) represents a new direction for a number of the team members formerly working on IronPython. PTVS brings the power of Visual Studio to any number of Python distributions including IronPython. The Python Tools for Visual Studio project is hosted on Microsoft's codeplex site. You'll find a wealth of information including documentation, FAQs, links to videos, and much more.


For this article we used a fresh 32-bit virtual machine version of Windows 7. The best news here is you don't need a full version of Visual Studio to use PTVS. You only need three files to get everything up and running. First you'll need to download and install the Visual Studio Integrated Shell. This gives you all the basic Visual Studio integrated development environment (IDE) tools but no language support. It will take a little while to install all the necessary pieces, so be patient. Figure 1 shows what you'll see when you launch the installer. Uncheck the box labeled "Yes, send information to Microsoft…" if you'd rather not transmit anything.

Microsoft Visual Studio 2010 Shell (Integrated) Installer
Microsoft Visual Studio 2010 Shell (Integrated) Installer

Next, you must install a Python distribution. The quickest and easiest way to get lots of Python functionality is to download the free Enthought Python Distribution. For Windows you'll have to upgrade to a paid version if you want native 64-bit support. The good news is you can use the 32-bit free version on 64-bit versions of Windows with no issues. EPD Free comes with Chaco, iPython, Matplotlib, Numpy, Scipy and Traits plus the entire Python standard library.

The last step involves downloading and installing PTVS. You'll find a download link on the front page of the PTVS codeplex site. The installer is distributed as an .msi file and should launch if you double-click on it from Windows Explorer. Once that completes you should be all set. Launch Visual Studio and you should see something like Figure 2.

Visual Studio 2010 Shell - Get Started
Visual Studio 2010 Shell - Get Started

 Click on New Project and you'll see something like Figure 3.

Visual Studio 2010 Shell - New Project
Visual Studio 2010 Shell - New Project


If you're a visual learner, you'll want to check out the videos produced by the PTVS team on YouTube. There are several covering the basic usage and how PTVS integrates with the Visual Studio environment.  Python is an interpreted language and, as such, provides an interactive facility for typing in commands and getting immediate feedback. PTVS accommodates this with an interactive window available through the View Other Windows menu or by using the Alt-I keyboard shortcut.

One of the really handy things you'll get with Visual Studio is Intellisense. Be aware that it takes almost fifteen minutes on a typical machine for the system to analyze the Enthought distribution, so it might not show up immediately after installation. Once the analyzing and indexing process completes you'll have full access to help for all available Python libraries.

You'll find all the standard Visual Studio debugging tools work as well. Setting breakpoints, examining local variables and stepping through code all work just as you'd expect (see Figure 4). You can also launch your code in the interpreter if you want access to the command line. There are a number of features provided by the interactive window including the ability to change scope from the main module to another module. There's Intellisense available in the interactive window for live objects, so you can quickly see the available methods on a user-defined class.

Standard Visual Studio Debugging Tools
Standard Visual Studio Debugging Tools

Wrap Up

In part two of this series we'll look at using PTVS along with Numpy and Scipy for doing scientific calculations and the Pyvot tool for interacting with Excel. PTVS is a great way to get started learning the Python language, especially if you're already familiar with Visual Studio.

Related Articles


  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there's simply not enough quality talent to go around. In response, companies often resort to inferior solutions -- hiring substandard developers and engineers, recruiting talent on a part-time or temporary basis, poaching people from competitors, or burdening an already stressed IT staff for more of their labor. Fortunately, there's a better solution. Read this white paper to learn the business value of …

  • As the mobile enterprise marketplace expands and customer needs grow more diverse, Samsung recognizes that solution partners and developers play an essential role by continually innovating to meet their customers' needs. Samsung works to provide these developers and partners with the latest tools and resources needed to create these solutions. Read this program guide to learn how the Samsung Enterprise Alliance Program provides partners and developers with Samsung enterprise software development kits (SDKs) …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date