0

So here is my problem : I wrote a script to connect to JMX service that needs to be run with Jython and that works perfectly ! I have also another script written in Python that is the « main » script of a bigger application that connects to different services by calling other Python scripts for each service.

The thing is I want this script to call and use the Jython one but without using an ugly method such as os.system("java -jar jython standalone jmx_with_jython.py..."), I found nothing online to call a Jython script from a python3 script…

If I start the main Python script with Jython I get a ton of lbraries errors because it uses Python2 following what I found on Internet (for example, one of them is : File "/my/dependencies/arguments.py", line 4, in <module> from urllib.parse import urlparse ImportError: No module named parse).

And on the other hand, if I start the main Python3 script with Python3 it can’t start the Jython one because it doesn’t recognize the javax module that is used to connect to JMX (ModuleNotFoundError: No module named 'javax' + I tried to install the module javax with pip for python3 and it didn't work).

the biggest probleme is that I can't change the "main" script and I don't want to modify the Jython one too. Any ideas to use my Jython script from my Python3 script?

1
  • Welcome to Stack Overflow. Please read How to Ask and minimal reproducible example, and show some code that can demonstrate the problem, along with clear steps for running it. Commented Jul 5, 2022 at 7:17

1 Answer 1

0

You could try running your Python 2 Jython script within Python 3 using execnet as described here Calling Python 2 script from Python 3

Sign up to request clarification or add additional context in comments.

1 Comment

execnet is not recommended for new projects. See pypi.org/project/execnet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.