在使用PythonEngine编译脚本之前,我将脚本的目录添加到引擎的搜索路径。这是我在C#代码中所做的:
string dir = Path.GetDirectoryName(scriptPath); ICollection<string> paths = engine.GetSearchPaths();if (!String.IsNullOrWhitespace(dir)){ paths.Add(dir);}else{ paths.Add(Environment.CurrentDirectory);}engine.SetSearchPaths(paths);现在,如果库位于您正在执行的脚本所在的目录中,则它们将是可导入的。



