0

我正在尝试使用 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);
4

1 回答 1

0

抱歉这个愚蠢的问题,结果证明 IronPython 在我的 C# 代码中使用的路径不正确。我刚刚更正了路径,一切正常。感谢 digEmAll。

于 2010-09-29T08:07:16.543 回答