java - jython 中的 Pythonnet
问题描述
我正在尝试通过 jython 从 java 执行用 python 编写的类和函数。它运行良好,直到在 python 中我们遇到“import clr”,即 pythonnet。
谁能告诉如何使用 jython 或任何其他使用“import clr”的东西从 java 运行 python 脚本
蟒蛇代码:file.py
import clr
使用 jython 的 java 代码:
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。
推荐阅读
- java - 当类彼此不相关但具有需要排序的公共属性时创建通用比较器
- docusignapi - DocuSign ISV 应用程序身份验证问题
- apache-spark-sql - 可以使用火花窗函数 first_value 吗?
- django - 如何使用 Nginx、Gunicorn 让 Jenkins 在端口 8080 上显示?
- c - 通过仅检查 char 数组的可变单个元素来使用 strncmp
- c++ - 将许多对象及其数据存储在来自 IMU 的数组中以供进一步计算
- python-3.x - 如何从正则表达式查找所有函数中获取第一个匹配项?
- oracle - ORA-00920: 第一次选择中的关系运算符无效
- python - 带有“while True”和“catch all exceptions”的线程有时会死掉
- python - 将 2 秒顺序数组转换为 pandas 数据帧