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?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Thoms R
  • 1
  • 1
  • Welcome to Stack Overflow. Please read [ask] and [mre], and show some code that can demonstrate the problem, along with clear steps for running it. – Karl Knechtel Jul 05 '22 at 07:17

1 Answers1

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

pzutils
  • 490
  • 5
  • 10