簡短的說法是,這看起來不是代碼問題(儘管如果任何人有一個編程方法可以讓我保持設計結構,那也可以)。當我在某些情況下嘗試導入任何模塊時,它無法正常工作。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