Sunday, May 24, 2009

Using IronPython with NetBeans Python IDE

With the arrival of the IronPython 2.6 beta 1, with ctypes support, the IronPython 1.x only support in IronPython Studio really takes the IDE from a bit dated to seriously obsolescent.

Now, I had tried to get IronPython 2.0 to talk with NetBeans, but hadn't immediately achieved success, so, with less motivation, had put that to one side. Perhaps for similar reasons, a recipe for this wasn't out on Google already -- but now I really needed to crack the problem, I wasn't going to let that earlier abject failure put me off.

Also, since then, I'd seen someone else doing similar stuff to get IronRuby to play with an IDE, in this case, RubyMine, by tinkering with the file actually getting called by the IDE.

Well, checking my Python 2.6.1 command line with -?, and the same for IronPython 2.6 beta 1, they overlapped in almost every essential. So, I tried the experiment of copying ipy.exe,ipyw.exe to python.exe,pythonw.exe in the same C:\Program Files\IronPython 2.6 folder, and then adding the copied python.exe as a new NetBeans Python platform.

And it worked!

So, I created a new python project for platform Python 2.6.0 (as opposed to CPython 2.6.1's Python 2.6), and entered

and ran it, which yielded

24/05/2009 14:28:30
2.6.0 (IronPython 2.6 Beta 1 (2.6.0.10) on .NET 2.0.50727.3074)

which is of course what we wanted.

2 comments :

Anonymous said...

If you go to Tools - Python Platforms, You can just define an IronPython platform like this:

Platform Name: IronPython 2.0
Commend: C:\Program Files\IronPython2\ipy.exe
Console Command: (same as above)
Command Arguments: -D

Your paths will probably be different. This is with Netbeans 6.5.1

Enjoy!

David Lawler

Steve Gilham said...

I'd tried that obvious approach the first time around, and it didn't get me a running script ... perhaps one end or the other has been suitably adjusted since the earlier experiment.