ninia / jep

Embed Python in Java
Other
1.33k stars 151 forks source link

Using jep in Java through Python host #458

Open injo11 opened 1 year ago

injo11 commented 1 year ago

Describe the problem We are using jep in our Java classes to do e.g. numpy calculations. But we also want to use those Java classes from standard Python, e.g. Spyder or Jupyter notebook. For the latter we use JPype. Now, if we use a Java class that uses jep, from JPype, the kernel just crashes. Is this scenario completely unthinkable, or is there some way of accomplishing this?

Environment:

bsteffensmeier commented 1 year ago

When jep loads the python library it calls several initialization functions. I would not expect it to be safe to call these when python is already running so I don't expect this to work. In my opinion it is unthinkable.

I have toyed with the jep code to try to get it to run embedding java into python, which would provide the type of functionality as jPype and it is theoretically possible. Since jep ould be setting up the environment it shoudl be possible to make new jep interpreters from java as well. Last time I looked at it was before we dropped support for python 2 and supporting both 2 and 3 was too much work so I set it aside. It is something I would like to look at again in the future but there are no concrete plans.

injo11 commented 1 year ago

If that happened it would be quite amazing, jep would then be bidirectional and use cases such as ours could then work (and you would not need the special jep-python jep command I guess).