>From the interactive python window I can import numpy and use it just fine.

Within C# however, I am having troubles getting it to import correctly.

I'm using:
string programPath = Path.Combine(rootDir, (string)args[0]);
Dictionary<string, object> options = new Dictionary<string, object>();
options["Debug"] = true;
ScriptEngine engine = Python.CreateEngine(options);
List argList = new List();
argList.extend(args);
ScriptScope sys = Python.GetSysModule(engine);
sys.SetVariable("argv", argList);
var sp = engine.GetSearchPaths();
sp.Add(@"c:\Program Files\IronPython2.7.1");
sp.Add(@"c:\Program Files\IronPython 2.7.1\DLLs");
sp.Add(@"c:\Program Files\IronPython 2.7.1\Lib");
sp.Add(@"c:\Program Files\IronPython 2.7.1\Lib\site-packages");
engine.SetSearchPaths(sp); 
ScriptSource source = engine.CreateScriptSourceFromFile(programPath);
int result = source.ExecuteProgram();

The python file:

import sys
sys.path.append(r'c:\Program Files\IronPython2.7.1')
sys.path.append(r'c:\Program Files\IronPython 2.7.1\DLLs')
sys.path.append(r'c:\Program Files\IronPython 2.7.1\Lib')
sys.path.append(r'c:\Program Files\IronPython 2.7.1\Lib\site-packages')
print "Running!"
import numpy


My response in the console window is as follows:

Running!
Command line arguments ['program.py']
File "c:\Program Files\IronPython 2.7.1\Lib\os.py", line 754
bs = b""

^
SyntaxError: invalid syntax


I also tried this with Python 2.7 and had the same result. Where am I going 
wrong?
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to