来自 Java 的 CPython?
我需要从 Java 调用 CPython 代码。有哪些工具/API/库可以帮助我做到这一点?
Jython 不是一个选项,因为 Python 代码严重依赖于 numpy。
编辑1:main()
函数应该是Java,而不是Python(即我需要将CPython嵌入到Java中,反之亦然。)
编辑2:我还应该提到我将传递大Java 和 Python 之间存在数字数组,因此将两者引入同一进程空间的解决方案将是更好的选择(但不是强制性的)。
I need to call CPython code from Java. What tools/APIs/libraries exist out there to help me do this?
Jython is not an option since the Python code is heavily dependent upon numpy
.
edit 1: The main()
function should be Java, not Python (i.e. I need to embed CPython into Java, not vice versa.)
edit 2: I should also mention that I'll be passing large numeric arrays between Java and Python and therefore a solution that brings the two into the same process space would be preferable (but not mandatory.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以查看使用 Jepp 将 CPython 嵌入到 Java 中。请阅读此处的文档。
编辑:对于 Windows,该项目已为 Python 2.4、2.5 和 2.6 预构建了二进制文件。对于Linux/Unix系统,你必须自己构建它。
You can take a look at using Jepp to embed CPython into Java. Read documentation here.
edit: For windows the project has prebuilt binaries for Python 2.4, 2.5, and 2.6. For Linux/Unix systems, you have to build it yourself.
您可能想阅读有关嵌入 CPython 解释器的文档。另外,关于如何在 Java 中加载本机库(称为 JNI 吗?)
You probably want to read the docs on embedding a CPython interpreter. Also, on how to load native libraries in Java (was that called JNI?)