Saturday, May 15, 2010

PythonNet and PythonService.exe

Well folks, just a week ago i was happy to discover PythonNet. Unfortunately it doesn't work
when its running under PythonService.exe which is the most natural way to run python as services as coded by Mark.

It runs fine in 32 bit Os, but the moment i tried it on Windows 2008 64 bit, it just terminated unexpectedly. The problem lies with the statement "import clr". i have exhausted all ways to get this working without writing my own pythonservice replacement and i conclude that its not usable
except for writing standalone tools that client need to manually click on or run by the scheduler.

Running the same program on a 64 bit OS manually works!, so the problem could lie in the
way python.runtime.dll is loaded by pythonservice.exe on "import clr".

Meanwhile, life goes on :-(, its back to .COM in .NET whenever we need Python to use certain calls to an existing .NET library.

Blogged with the Flock Browser

Tuesday, May 4, 2010

python and .net – unlikely symbiosis


If you love python and want to use all the libraries of python but you also need to work on .NET projects. You might be tempted to look at IronPython…but unless MS openly supports IronPython in VS and also all those libraries that makes Python such a kick ass language, you should skip it.

On the other hand, I found “pythonnet”, this is probably one of the best answer on using python and .net .

All you need to do is copy the clr.pyd file to ur python installation directory and also the python.runtime.dll file and you can do things  like …

import clr
import System.Windows.Forms as WinForms
from System.Drawing import Color, Size, Point
from System.Text import Encoding
from System.IO import File
import System

class Wordpad(WinForms.Form):
    """A simple example winforms application similar to wordpad."""


Cool like hell!.