我正在尝试为IronPython构建一个带有交互式控制台的web应用程序。当我尝试在IronPython的普通控制台中导入xmlrpclib时,它可以正常工作。但是,如果我在C#代码中使用IronPython,它会抛出一个异常"No module named xmlrpclib“。这是一个已知的问题吗?有什么解决方案来解决这个问题吗?
代码如下:
var testCode = @"
import xmlrpclib;
APIServer = xmlrpclib.ServerProxy('address', allow_none=True);
print APIServer.Hello();
";
MyStream str = new MyStream();
ScriptEngine engine = Python.CreateEngine();
engine.Runtime.IO.SetOutput(str, System.Text.Encoding.ASCII);
engine.Runtime.IO.SetErrorOutput(str, System.Text.Encoding.ASCII);
ScriptScope scope = engine.CreateScope();
ScriptSource src = engine.CreateScriptSourceFromString(testCode);
src.Execute(scope);发布于 2010-09-29 16:07:17
对于这个愚蠢的问题,我很抱歉,结果是我的C#代码中的IronPython使用的路径不正确。我只是更正了路径,一切工作正常。感谢digEmAll。
https://stackoverflow.com/questions/3819274
复制相似问题