How to install IronPython2 with Mono on Ubuntu

This is just an instructional post with the hope that it might help others in the future.

I spent a long time trying to get IronPython2 running on Mono. Now IronPython1 ships with Ubuntu, so
apt-get install ironpython
, if that's all that you want. Ironically, I don't really know the difference between IronPython1 and IronPython2, but "2 has got to be better than 1", right?

The good news is that its very possible, but you will have to step out of your comfort zones.

You will need:
Mono 2.4 (sources) and IronPython 2.0.1 (binary)

First build Mono (note that you need Ubuntu's Mono to bootstrap, so
apt-get install mono
) but make sure you put it somewhere special so it doesn't mess with the system-installed Mono. This advice is taken from an article on the Mono wiki.


$ tar xvjf mono-2.4.tar.bz2
$ cd mono
$ mkdir -p ~/opt/mono
$ ./configure --prefix=~/opt/mono
$ make && make install


So this is putting Mono in opt/mono in my home directory (which is where I like to put things, but you might like them somewhere else, like /opt).

Then you will need to write a script. Again modified from the link above.


#!/bin/bash
MONO_PREFIX=~/opt/mono
export DYLD_LIBRARY_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig
PATH=$MONO_PREFIX/bin:$PATH
PS1="[mono] \w @ "


You will source this script to mutate your environment so you can use your nice new Mono, so say you saved it as ~/mono-2.4-env-activate.sh:


source ~/mono-2.4-env-activate.sh


And it will do its busines and change your prompt so you know it:


[mono] ~ @


And once you have that you can test it:


[mono] ~ @ which mono
/home/ali/opt/mono/bin/mono
[mono] ~ @ mono --version
Mono JIT compiler version 2.4 (tarball Sat May 23 01:13:11 BST 2009)


And once you are happy it works, you just need to execute the IronPython2 executable.


[mono] ~/tmp @ unzip IronPython-2.0.1-Bin.zip
[mono] ~/tmp @ cd IronPython-2.0.1/
[mono] ~/tmp/IronPython-2.0.1 @ mono ipy.exe
IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.1433
Type "help", "copyright", "credits" or "license" for more information.
>>>


Looking good! And before you kill yourself trying to exit (it wants
Control-z
which is going to be fairly impossible):


>>> import sys
>>> sys.exit()
[mono] ~/tmp/IronPython-2.0.1 @


And there you have it. I am not sure exactly how I feel about IronPython on Mono, but it can't be a bad thing that it works. I will be investigating it more in the near future, so I may document what I am learning.

Popular posts from this blog

PyGTK, Py2exe, and Inno setup for single-file Windows installers

ESP-IDF for Arduino Users, Tutorials Part 2: Delay