Using SciPy with IronPython

Three years ago I wrote a post about my disappointment using SciPy with IronPython. A lot has changed since then, so I thought I’d write a short follow-up post.

To install NumPy and SciPy for use with IronPython, follow the instructions here. [Update: no longer available.] After installation, NumPy works as expected.

There is one small gotcha with SciPy. To use SciPy with IronPython, start ipy with the command line argument -X:Frames. Then you can use SciPy as you would from CPython. For example.

c:> ipy -X:Frames
>>> import scipy as sp
>>> sp.pi
3.141592653589793

Without the -X:Frames option you’ll get an error when you try to import scipy.

AttributeError: 'module' object has no attribute '_getframe'

According to this page [link rot],

The issue is that SciPy makes use of the CPython API for inspecting the current stack frame which IronPython doesn’t enable by default because of a small runtime performance hit. You can turn on this functionality by passing the command line argument “-X:Frames” to on the command line.

8 thoughts on “Using SciPy with IronPython

  1. I wish matplotlib would work. It would be a great setup to have a model written in C# (which I do) and then use python to drive it and produce graphs etc.

  2. Daniel: IronPython interfaces seamlessly with .NET managed code, but you have to go through an extra hop to use anything with native code inside. Modules implemented in pure Python are OK, but modules written as Python wrappers around C code are not. That’s why SciPy was awkward to use from IronPython at first, before Enthought developed a .NET version of SciPy.

    Before the Enthought release, you could call SciPy via Ironclad. I haven’t kept up with that project, but perhaps it would let you use matplotlib from IronPython.

  3. hi john, I appreciate your notes on running numpy with ironpython. I’m coming from a unix background and having a really hard time figuring out how to pull off this install, especially since the install instructions on the enthought page are no longer up. do you have a copy of the instructions / installation file? thanks so much, K

  4. kendra: I don’t know what happened. I’ve sent an email to Enthought asking where the page may have moved to.

    Update: The link works again.

  5. Do you know if there is a 64-bit version of Numpy and scipy for IronPython?
    Also does IronPython 2.7.3 (just released July 2012) changes things at all?

    Thanks,
    Petrarca

  6. i have to admit i don’t get iron python, u may as well use vb if u need to do some .net code it’s easier xD, i just discovered python though i do love it, numpy solved the one issue i had with it, it’s now my second fave language over vb.net, helping me get away from the .net platform lol :)

    as opposed to you guys who obviously want to leverage your python skills with .net

  7. Hello i am starsky and i am trying to install numpy in ironpython. The link were the instrutions are is dead. Is the someone who have those instrution thanks.

Comments are closed.