PythonEmbed
Run Python code from Java — with full CPython compatibility and zero setup.
PythonEmbed embeds a real CPython interpreter in your JVM application via a subprocess + MessagePack binary protocol — just pure Java and CPython. All C extensions (numpy, scipy, torch) work out of the box.
Quick Look
Add the Gradle plugin:
Then run Python from Java:
try (PythonEmbed py = PythonEmbed.create()) {
py.exec("import numpy as np");
int sum = py.eval("sum([1, 2, 3])").asInt(); // 6
}
Next Steps
- Quickstart — Get running in 5 minutes
- Installation — Gradle plugin and runtime setup
- Usage Guides — eval, exec, pool, callbacks, streaming, and more
- Spring Boot — Zero-code auto-configuration
- Examples — 13 real-world examples
- API Reference — Full method documentation
- Architecture — How it works under the hood