12

We have some Java code we want to use with new code we plan to write in Python, hence our interest in using Jython. However we also want to use numpy and pandas libraries to do complex statistical analysis in this Python code.

Is it possible to call numpy and pandas from Jython?

user2895685
  • 121
  • 1
  • 1
  • 3
  • welcome to stackoverflow! please look for duplicates when posting questions - e.g. http://stackoverflow.com/questions/3097466/using-numpy-and-cpython-with-jython – Corley Brigman Oct 18 '13 at 17:17
  • 3
    saying that, the answer to that question, and its answers, are rather old so may not be up to date... – Andy Hayden Oct 18 '13 at 18:06
  • 3
    The above link is from 3 years ago, and I saw some mention that perhaps this may work now. Hence the question. Is this still true in 2013? – user2895685 Oct 18 '13 at 19:11

4 Answers4

5

Keep an eye in JyNI which is at alpha.2 version, as of March-2014.

ankostis
  • 8,579
  • 3
  • 47
  • 61
4

Not directly.

One option which I've used in the past is to use jsonrpclib (which works for both) to communicate between python and jython. There's even a server builtin which makes things quite simple. You'll just need to figure out whether the gains of using numpy are worth the additional overhead.

sarwar
  • 2,835
  • 1
  • 26
  • 30
2

Especially if you don't want to use raw Numpy, but other Python frameworks that depend on it, JyNI will be the way to go once it is mature. However, it is not yet capable to import Numpy.

Until then you can use Numpy from Java by embedding CPython. See the Numpy4J-project for this (I didn't test it myself though).

stewori
  • 586
  • 4
  • 12
0

You can't use numpy from Jython at this time. But if you're willing to use CPython instead of Jython, there are some open source Java projects that work with numpy (and presumably pandas).

ndjensen
  • 129
  • 1
  • 3