Python Programming in Windows

These are the pieces needed for a basic working Python setup.


I've been using the Python programming language for modeling work. The primary reason is that it's an easy programming language to learn. This is one of Python's primary goals; teaching it to biologists fits nicely with their "Computer Programming For Everybody" ideas. Python is also free and available for a wide variety of platforms.

  1. Download the Windows Python installer from the Python Download page. You should download the "Windows Installer" for the latest version.
  2. Get the python-x.x.x.exe file and run it. You can just go with the defaults and let it install itself.
  3. You should now have a Python item in your Program menu. You can run either "IDLE (Python GUI)" or "Python (command line)" to use the Python in interactive mode (type control-Z to leave either). You can also just double-click Python programs (.py and .pyc files) to run them. See below for more on working with programs.


The numarray add-on package gives an efficient multi-dimensional array type to Python. If you don't know what that means, just trust me that this modeling stuff would be a lot uglier without it.

  1. Download the latest Windows version of numarray. You can get it from the numarray download page. The file you want is numarray-?.?.win32-py?.?.exe from the latest release. At the moment, this is the 1.1.1 release of numarray for Python 2.4
  2. Run the file you downloaded. If Python is installed correctly, you should be able to just accept the defaults to install numarray.
  3. To test if numarray is installed, run the Python interpreter and type import numarray. If no error message appears, it's installed. (Type control-Z to leave the interpreter.)

Working with Python programs

Once you have everything installed, you should be able to run Python programs. You can try the patch selection program—it should run in a few seconds and create a file patch.txt in the same directory that you saved the program.

If you want to edit a program, you can use any text editor. The easist thing to do is use the program called "IDLE" (Integrated DeveLopment Environment) that was installed with Python.

  1. From the Start menu, select "Python" and "IDLE (Python GUI)". You should see the "Python Shell" window.
  2. From here, you can open and edit Python programs (.py files) by selecting "Open" from the "File" menu.
  3. If you are working on a program and want to run it, you can select "Run module" from the "Run" menu (or press F5). The output from the program will appear in the "Python Shell" window.
  4. If you want to stop a program that's already running (because it doesn't look like it's going to stop or because you want to make a change and start again), you can select "Restart Shell" from the "shell" menu.

Any files that the program creates are generally left in the same directory as the program you're running.

Copyright © , last modified 2010-07-14.