来自 Java 的 CPython?

发布于 2024-10-04 13:46:57 字数 262 浏览 0 评论 0原文

我需要从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墨落画卷 2024-10-11 13:46:57

您可以查看使用 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.

溺孤伤于心 2024-10-11 13:46:57

您可能想阅读有关嵌入 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?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文