jython 中的 Pythonnet

Pythonnet in jython

我正在尝试通过 jython 从 java 执行 class 和用 python 编写的函数。 它 运行 很好,直到在 python 中我们遇到了“import clr”,它是 pythonnet。

任何人都可以告诉如何使用 jython 或任何其他使用“导入 clr”的东西 运行 来自 java 的 python 脚本

python代码:file.py

import clr

java 使用 jython 的代码:

Properties props = new Properties();
Properties preprops = System.getProperties();
PythonInterpreter.initialize(preprops, props, new String[0]);
PythonInterpreter interp = new PythonInterpreter();
interp.exec("<absoulute_path//file.py>");

错误:

Exception in thread "main" Traceback (most recent call last):
  File "<string>", line 3, in <module>
ImportError: No module named clr

Jython 不提供 Python C API,因此您无法构建和使用 Python.NET。