【问题标题】:java jython Import errorjava jython导入错误
【发布时间】:2016-11-12 13:51:02
【问题描述】:

我使用 jython 在 java 中调用 python 脚本(使用 3rd lib pykriging)。但是我在 java 控制台中得到 ImportError 。我尝试了很多方法,但都没有奏效。 我的代码是这样的:

  public static void main(String[] args) {

    Properties props = new Properties();
    props.put("python.home","D:\\prog\\Python27");
    props.put("python.console.encoding", "UTF-8");
    props.put("python.security.respectJavaAccessibility", "false"); //don't respect java accessibility, so that we can access protected members on subclasses
    props.put("python.import.site","false");
    Properties preprops = System.getProperties();

    PySystemState.initialize(preprops, props, new String[0]);
    PySystemState sys = Py.getSystemState();
    sys.path.append(new PyString("D:\\prog\\Python27"));
    sys.path.append(new PyString("D:\\prog\\Python27\\Lib\\site-packages"));

    PythonInterpreter interp = new PythonInterpreter();
    interp.execfile("pyt/example.py");

}

错误是这样的:

【问题讨论】:

    标签: java jython


    【解决方案1】:

    也许没有办法使用它,因为'pykriging'依赖于'numpy',但这不是在jython中使用numpy的好方法。 Using NumPy and Cpython with Jython

    【讨论】:

    • 考虑不要在 10 分钟后自己写答案;而是更新您的问题。
    猜你喜欢
    • 2013-02-07
    • 2017-10-13
    • 2016-04-02
    • 1970-01-01
    • 2018-06-30
    • 1970-01-01
    • 1970-01-01
    • 2013-01-30
    • 1970-01-01
    相关资源
    最近更新 更多