我对Python一点都不熟悉,希望有人能帮助和指导我找出这里出了什么问题。在
以下是错误消息:
MissingMemberException: 'LightException' object has no attribute 'etree'
这是抛出它的python代码:
import xml.etree.ElementTree as ET
我们在一个c项目中使用IronPython2.7.3,python代码使用Execute()方法执行:
private void Execute(string code, ScriptScope scope)
{
try
{
PythonByteCode compiled = (PythonByteCode)Compile(code, SourceCodeType.AutoDetect);
compiled.Execute(scope);
}
catch (Exception e)
{
throw new PythonParseException(e);
}
}
这很容易。运行引擎时,它不知道默认的程序集位置(在我的机器上是“C:\ProgramFiles(x86)\IronPython2.7”)。因此,它尝试从当前工作目录中获取模块,然后从工作目录的-
Lib
子目录中获取模块。当然,它在那里找不到模块。你应该做什么:
获取IronPython发行版的路径。实际上,您需要
Lib
子目录内容。也许您应该考虑如何在目标计算机上部署它,这样您的发布版本也可以找到它。在使用下面的代码将其添加到python搜索路径
相关问题 更多 >
编程相关推荐