简短的说法是,这看起来不是代码问题(尽管如果任何人有一个编程方法可以让我保持设计结构,那也可以)。当我在某些情况下尝试导入任何模块时,它无法正常工作。IronPython有时会导入模块,但不会导入其他模块
import sys
sys.path.append('C:\Python26\Lib')
sys.path.append('C:\Users\<user>\Documents\Visual Studio 2010\Projects\<Solution>\Simulation')
import time # errors out
from XMLRPCBridge.python_ClientAPI.AsyncXMLRPCClient import AsyncXMLRPCClient, RPCPriority # if I remove the previous line this one errors instead
Python的文件使用加载以下
public class StateSimBridge
{
private ScriptScope pythonModule = Python.CreateRuntime().UseFile("..\\..\\..\\Simulation\\AsyncClientPatch.py");
// errors out before getting any farther than this
...
}
当我实例从一个伪主线程类项目中的这一切工作正常 然而,当我从另一个项目间接加载它我收到有关'没有这样的模块'错误的错误。
public sealed class SimulationDriver
{
private static readonly Lazy<SimulationDriver> lazy = new Lazy<SimulationDriver>(() => new SimulationDriver());
private StateSimBridge.StateSimBridge simulationBridge = new StateSimBridge.StateSimBridge("Garmsir");
static SimulationDriver()
{
}
private SimulationDriver()
{
}
public static SimulationDriver Instance
{
get { return lazy.Value; }
}
...
}
我什至不知道还有什么要测试在这一点,所以任何帮助表示赞赏。
编辑:为了说清楚,我在两种情况下都检查了sys.path,并且两个条目都成功添加了。令我困惑的是,就IronPython而言,这两种情况之间会有所不同。
输入是赞赏,我试图确保(没有区别)。但正如我所提到的,在一种情况下在IronPython下运行时,它可以正常工作,而不是在另一种情况下。当以纯Python运行时,它也可以正常工作。我也尝试在两种情况下打印路径,并且它们也是一样的。这两次他们仍然提出了相关的路径。 – Shaman