asp.net - Calling a Python script with Arguments using IronPython - "Need more than x values to unpack" -


i'm using following c# code call python script using ironpython:

scriptengine scriptengine;  var opts = new dictionary<string, object>(); opts["arguments"] = new[] {      server.mappath(@"~\processing\input.7z"), // input     server.mappath(@"~\processing\key.pem"),  // key     server.mappath(@"~\processing\") };       // output         scriptengine = python.createengine(opts);  var sp = scriptengine.getsearchpaths(); sp.add(server.mappath(@"~\python\lib")); scriptengine.setsearchpaths(sp);  var scope = scriptengine.runtime.executefile(server.mappath(@"~\python\test.py")); 

the script takes following arguments:

arg0,input,key,output = sys.argv 

i'm getting error "need more 3 values unpack". doing wrong?

the line

arg0,input,key,output = sys.argv 

unpacks list of arguments in sys.argv 4 variables on left. since there 3 arguments in sys.argv, fails error message posted (apparently need manually pass in script path appear first element in sys.argv).

try different way of passing in command-line arguments (from this answer):

scriptengine.sys.argv = list.make(new[] { 'input.7z', ... }); 

alternatively, if doesn't work, either remove arg0 variable assignment in python file, or add script's path explicitly first argument in c#.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -