NLTK with IronPython: Installation
I’m trying to use the Natural Language Toolkit with IronPython. The following steps have worked fine so far:
-
Download and install IronPython. I’m using version 2.7.1 Beta 2 on Windows 7. Make sure that ipy can be called from the command line. After executing ipy via command line, you should see something like this:
IronPython 2.7.1 (2.7.0.40) on .NET 4.0.30319.237 Type "help", "copyright", "credits" or "license" for [...] >>>
- NLTK requires PyYAML so you have to download the source package from here. I’m using version 3.10. Extract the zip file and install it from the command line via
ipy setup.py install
Depending on your Windows version and configuration, you might have to execute the command line as administrator.
- Download the source package of NLTK, extract the zip file and install it via
ipy setup.py install
Now you can start IronPython and can try to import NLTK:
IronPython 2.7.1 (2.7.0.40) on .NET 4.0.30319.237 Type "help", "copyright", "credits" or "license" for more information. >>> import nltk >>>
If you don’t get any errors, everything should be fine so far. I was not yet able to execute the examples given on the NLTK page. Most of them require some corpora which have to be downloaded via NLTK, but the provided helper method fails due to a missing expat library. As soon as I’ll have a working expat version for IronPython, I’ll report further progress.
Update:
Just download this file and store it as expat.py into the Lib\xml\parsers folder below your IronPython installation. The graphical demos on the getting started page of NLTK are still not working, but that was expected. Other demonstrations seem to work so far.
-
Meta




