Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run/debug Python code which is dependent on Java objects from Python end #558

Open
georgea3 opened this issue Sep 9, 2024 · 3 comments

Comments

@georgea3
Copy link

georgea3 commented Sep 9, 2024

I have Python objects which depend on Java classes and so use import statements (of the Java classes) in the Python classes.
Naturally, using Jep, I can run my Python code (and indeed debug my Python code too) from my Java application fine.
My issue however is that if I want to run/debug some Python code, I always have to run it through the Java application.
If I just try to run some Python code from my Python IDE (e.g. PyCharm), I get errors about the Java import statements in the Python classes.
So my question is, is there is a way to run/debug Python code, which is integrated with Java classes, from the Python side such that the imported Java classes can be found?

  • OS Platform, Distribution, and Version: Windows and Linux
  • Python Distribution and Version: 3.11.4
  • Java Distribution and Version: 21.03
  • Jep Version: 4.1.1
  • Python packages used (e.g. numpy, pandas, tensorflow): numpy 1.24.3, pandas 2.0.3, tensorflow 1.13.0

Thanks.

@ndjensen
Copy link
Member

Jep currently only supports running a Java process with CPython embedded inside it. It does not support running a Python process with a JVM inside it. @bsteffensmeier and I have discussed adding the ability to embed the JVM in a Python process which would add what you're looking for, but I don't think either of us considers it a priority to be worked at this time.

You could do something like the the Jep tests which has a pretty simplistic Java main() that just immediately calls over to Python. But I realize that doesn't take advantage of IDE conveniences and it is not a great solution.

@georgea3
Copy link
Author

Thanks for the feedback. Its a shame this is not a priority as I suspect its a problem for most developers in this space.

@ryanmkurtz
Copy link

Have you tried jpype?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants