PC204 --- Interactive Development Environment for Windows


PythonWin sample image

PythonWin is the name of the interactive development environment (IDE) that is part of the Python for Windows extensions. It provides a simple graphical interface for editing and running Python programs on computers running the Microsoft Windows operating systems.

The figure on right shows a PythonWin with an editor window, where a Python source file may be written and modified, and a Python interpreter window, where one can type in and execute Python code. The toolbar above the main area provides buttons for a variety of functions such as Run, Check, etc.


Start menu image

To install PythonWin on your Windows computer, you will need to download an installer from the open source project Python for Windows extensions hosted at SourceForge. When you visit the page, you will see many different PythonWin installer files. You will need to select the one that matches your Python installation. For example, if you installed the standard 32-bit Python installer (python-2.7.msi), then you will need the pywin32-214.win32-py2.7.exe installer. Similarly, if you installed the 64-bit Python installer (python-2.7.amd64.msi), then you will need the matching pywin32-214.win-amd64-py2.7.exe installer.

Once you've downloaded the proper installer, double-click on the file to start installation. Upon completion, there should be a new PythonWin entry in the Start menu. If you have a Python 2.7 menu, PythonWin should appear in there as well.


To run PythonWin, just click on its Start menu item. The user interface is similar to the Firefox web browser, with a menu bar across the top and a toolbar immediately below. Upon starting, the only open window is the Interactive Window, where you can type and execute Python code directly. Note that hints pop up as you type. For example, try typing:

import sys
print sys.executable
When you typed the period in the second line, you should see a pop-up window listing all the attributes in the sys module.

Code typed into the Interactive Window are not saved anywhere. To save code in files, use the File->New menu item and select Python Script for the file type. That should bring up an editor window where you can type in Python code. Note that, unlike in the Interactive Window, the code is not executed immediately. Instead, you will need to File->Save As... to save the file first, then click the little running man icon to execute the file. Any output from your script will appear in the Interactive Window.

Import Search Path

PythonWin searches the standard Python paths when importing modules. If you have a folder containing a set of modules, e.g., swampy, you can insert some code at the top of your script to tell Python to search additional folders. For example, if you want to import the TurtleWorld.py module from the swampy folder E:\home\conrad\swampy, then you can use the following:

import sys
sys.path.insert(0, "E:\\home\\conrad\\swampy")

import TurtleWorld
The first two lines tell Python that there is an extra folder in which to search for modules. (Note that you need to double the backslashes because of the way Python treats the backslash escape character.) After that, the TurtleWorld module can be imported normally.

Last updated: October 7, 2010