2010-09-29 38 views
0

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

你可以发布你的C#代码吗? – digEmAll 2010-09-29 06:54:27

+0

我已经添加了代码片段。 – Andy 2010-09-29 07:51:12

+0

你确定搜索路径('sys.path')在C#中是否相同,并且直接来自python? – digEmAll 2010-09-29 07:51:21

回答

0

对不起,愚蠢的问题,事实证明,使用IronPython的我的C#代码中的路径是不正确的。我只是纠正了路径,一切正常。感谢digEmAll。