Call Jython from Python (or vice versa)

I'm working on a frame right now, part of which requires Jython. I just added some graphs to it using MatPlotLib, not realizing that MatPlotLib is incompatible with Jython. Since these two parts are pretty isolated, and I would have worked great on most of the Python program and passed a little information to the Jython part (or vice versa), I was wondering if there is an easy way to do this while maintaining the modular nature of the structure. Ideas?

+7
source share
2 answers

I did not use execnet for something serious, but it is possible that this is a good choice for you. execnet is a Python library for distributed execution across all versions, platforms, and network barriers.

It’s easy to get started. This simple Jython script (which calls NumPy) worked without me:

import execnet gw = execnet.makegateway("popen//python=python") channel = gw.remote_exec(""" from numpy import * a = array([2,3,4]) channel.send(a.size) """) for item in channel: print item 

Exit:

 3 

The documentation provides an example that goes in the opposite direction (CPython interpreter connecting to the Jython interpreter).

+11
source

Do not use MatPlotLib with execnet ...

But...

For a quick check using execnet (on win32 platform) you can use PortablePython2.7.2.1

PortablePython contains MatPlotLib and is easy to install (and uninstall)

0
source

All Articles