I'm trying to execute a Python script from within a C# application but when it tries to launch the script, I receive the error ImportException was unhandled
No module name csv
. I checked the Ironpython folder and there is a csv.py file...?
Code I'm using to call the script:
IDictionary<string, object> options = new Dictionary<string, object>();
options["Argument"] = new[] { filePath, profile };
var pyEngine = Python.CreateEngine(options);
var pyScope = pyEngine.CreateScope();
string script = "xccdf-xml2tsv.py";
pyScope.SetVariable(profile, options);
pyEngine.ExecuteFile(script, pyScope);
python file:
#!/usr/bin/env python
###
# (C) 2010 Adam Crosby
# Licensed under:
# http://creativecommons.org/licenses/by-nc-sa/3.0/
##
import csv
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import xml.etree.ElementTree as ET
xmlns = "http://checklists.nist.gov/xccdf/1.1"
...