views:

73

answers:

1

I want to execute python code from C# with following code.

   static void Main(string[] args)
    {
        ScriptEngine engine = Python.CreateEngine();
        ScriptSource source = engine.CreateScriptSourceFromFile(@"F:\Script\extracter.py");
        source.Execute();
    }

I have the problem at line source.Execute(), I got error "No module named difflib".
What is wrong in my code?

This is my python code (extracter.py).

import re
import itertools
import difflib
print "Hello"
+3  A: 

This looks like your engine does not have access to Python standard library - it does not see difflib.py. Either fix the sys.path or copy difflib.py from Python 2.6 to f:\script folder.

re and itertools modules are written in C# and are part of IronPython.modules.dll - that's why importing them work.

Lukas Cenovsky