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"
This looks like your engine does not have access to Python standard library – it does not see
difflib.py. Either fix thesys.pathor copydifflib.pyfrom Python 2.6 tof:\scriptfolder.reanditertoolsmodules are written in C# and are part ofIronPython.modules.dll– that’s why importing them work.