我正在尝试使用 IronPython 的交互式控制台构建一个 Web 应用程序。当我尝试在 IronPython 的普通控制台中导入 xmlrpclib 时,它可以工作。但是,如果我在 C# 代码中使用 IronPython,它会引发异常“没有名为 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);