Python Tools for Visual Studio

Python Tools for Visual Studio

Install the tools

The tools are available on the official CodePlex for the Python Tools for Visual Studio –
Just go to the Downloads section. Here you will have several options: Python Tools for Visual Studio 2012, Python Tools for Visual Studio 2010, and some samples. Download the msi installer which fits your needs best. If you want to have a look at some sample implementations, which are also available in the documentation, you can download them on the same site.

The interpreters

Python currently has two popular versions: 2.7 and 3.x. The recommended one for the Python Tools is version 2.7. To find out which interpreters are installed on your machine open Visual Studio and open the Python Interpreters windows (Tools – Python Tools – Python Interpreters).

Python Interpreters

A window like the one above will be opened. On this PC there are currently the versions 2.7 and 3.3 installed. If there is no Python version installed before this window will be empty. How to get a Python version? Option #1 would be to click the link Go online and help me find another interpreter. The second option is to browse to the official Python page and open the download section. There are most of the current Python interpreters.

Create a simple Python project

Now that we have setup the environment let us create a small Python application. To create a Python application click File – Project – New Project. In the New Project screen you will see all the common project types – and Python.

New Project

From here you can create several project types:

  • Create an application from existing Python code
  • A normal Python application
  • A Django application
  • An IronPython application
  • An IronPython Windows Presentation Foundation application
  • An IronPython Silverlight website
  • An IronPython Windows Forms application

To keep things simple I choose the normal Python application project type. This creates the following skeleton:


Most interesting for us at this point are the Python Environments and the file. Let’s start with the Python environments. Currently there’s only the default Python interpreter associated with our project (the one which is bolded in the Python interpreters window). To add other interpreters right-click Python Environments and select Add/Remove Python Interpreters…

The opened window gives you the chance to select the Python environment to use with this project. In this sample I would like to use both of my installed interpreters, Python 2.7 and Python 3.3.

Python Environments

If you click the small arrow beside your environment you will see the packages installed along with this interpreter. If you want to install other packages right-click the appropriate interpreter and choose Install Python Package…
One thing to notice at this point: If you install packages this way they will also be available in other projects. What’s the problem? Imagine the following situation: You’re working on two different projects and you need to work with two different versions of the Azure tools. To prevent conflicts in the packages you can create a virtual environment, which is like a clone of an interpreter, but the packages are limited to the project where the virtual environment lives in. To create a virtual environment right-click Python Environments and choose Add Virtual Environment…
The following dialog gives you the options to give it a name and select the interpreter the virtual environment will created from.

At this point we have done several things:

  • We have installed the Python Tools
  • We installed another interpreter
  • We created a Python application
  • We created a virtual environment

What’s missing? Some simple code!

Before we start we have to make sure that our virtual environment is our current one. Right-click the virtual environment and select Activate Interpreter.

Alright, let’s create a simple greeter. The Python code looks like this

01.import os
03.def greet(name):
04.  print('Hello {0}'.format(name))

This will greet Thomas, Robert, and Judith for us. I recommend to type the code yourself to see how the Visual Studio Intellisense helps you writing.


The Python Tools for Visual Studio makes it easy to work with Python inside of Visual Studio. In this blog post we have installed the tools, installed an interpreter, created a simple Python greeter, and added a virtual environment to our project.

Leave a Comment
  • Please add 3 and 5 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
  • Carsten Siemens edited Original. Comment: Added tags: en-US, has TOC

Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
  • Carsten Siemens edited Original. Comment: Added tags: en-US, has TOC

Page 1 of 1 (1 items)