IronPython cannot import module “os”

♀尐吖头ヾ 提交于 2019-12-03 08:31:20

When hosting IronPython in your code, you'll need to add the libraries to your path. Not all will be included by default.

You can add it through the engine:

var engine = Python.CreateEngine();
var paths = engine.GetSearchPaths();
paths.Add(@"C:\Program Files (x86)\IronPython 2.7\Lib");
//paths.Add(@"C:\Python27\Lib"); // or you can add the CPython libs instead
engine.SetSearchPaths(paths);

Or through your script:

import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
import os
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!