Invoking Jython from Python (or Vice Versa)

前端 未结 2 1282
失恋的感觉
失恋的感觉 2020-12-09 22:25

I\'m working on a framework right now, part of which requires Jython. I just added some plotting to it using MatPlotLib, without realizing that MatPlotLib is incompatible wi

相关标签:
2条回答
  • 2020-12-09 22:51

    Didn't use MatPlotLib with execnet ...

    But ...

    For a quick tryout with execnet (on a win32 platform) you can use PortablePython2.7.2.1

    PortablePython contains the MatPlotLib and is easy to install (and remove)

    0 讨论(0)
  • 2020-12-09 22:58

    I have not used execnet for anything serious, but it seems quite possible that it is a good choice for you. execnet is a Python library for distributed execution across version, platform, and network barriers.

    It is not hard to get started. This simple Jython script (that invokes NumPy) worked for me without a hitch:

    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
    

    Output:

    3
    

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

    0 讨论(0)
提交回复
热议问题