Getting started with IronPython

I’ve just started experimenting with IronPython, Microsoft’s implementation of Python built on .NET. You can download IronPython from CodePlex either as an MSI installer or a zip file of binaries. I installed it from the zip file on one computer and from the MSI on another. I highly recommend the latter.

Installing from the zip file

The CodePlex download page has three files:

  • IronPython.msi

My first thought was that I wasn’t interested in compiling IronPython from source, so I’d just download the bin file since it was smaller. I downloaded it, unzipped it, and copied it over to my C:bin directory. (I have a habit of installing languages in C:bin to placate software that assumes paths don’t contain spaces.  For example, if you install R in the default C:Program Files location, some add-ons will break.) The typical command line “hello world” program worked just fine. The example from the readme file on how to pop up a window using WinForms worked fine as well. But my attempt to use a standard library by typing import urllib didn’t work. The standard Python modules are not in the search path by default. The tutorial that comes with IronPython explains how to fix this.  I added the following two lines to and then was able to use standard modules like urllib .

import sys

I had a non-ferrous version of Python installed already in C:binPython25 so I just reused those files. The tutorial explains where to get the standard library files if IronPython is the first Python you install.

Installing from the MSI file

On a different computer, I downloaded the MSI file and ran it. This was a much nicer experience. The installer has a check box to run NGen on the .NET code in IronPython. I checked this box assuming it would make IronPython run faster in the future.

The standard modules worked immediately with no configuration on my part.The installer created a sophisticated file that builds the path on start-up. Presumably this file will add new modules to my path as I install things in the future.

2 thoughts on “Getting started with IronPython

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>