execnet无法运行python到jython

2024-05-29 11:39:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图从http://codespeak.net/execnet/example/hybridpython.html运行一个示例,但python在线上冻结了:

gw = execnet.makegateway("popen//python=jython")

示例:

import execnet
gw = execnet.makegateway("popen//python=jython")
channel = gw.remote_exec("""
    from java.util import Vector
    v = Vector()
    v.add('aaa')
    v.add('bbb')
    for val in v:
        channel.send(val)
""")

for item in channel:
    print (item)

我是Debian Jessie


Tags: inimportadd示例forchannelvaljython
1条回答
网友
1楼 · 发布于 2024-05-29 11:39:42

如果您阅读了文档,则定义如下

def makegateway(self, spec=None):
    """create and configure a gateway to a Python interpreter.
    The ``spec`` string encodes the target gateway type
    and configuration information. The general format is::

        key1=value1//key2=value2//...

    If you leave out the ``=value`` part a True value is assumed.
    Valid types: ``popen``, ``ssh=hostname``, ``socket=host:port``.
    Valid configuration::

        id=<string>     specifies the gateway id
        ***python=<path>   specifies which python interpreter to execute***
        execmodel=model 'thread', 'eventlet', 'gevent' model for execution
        chdir=<path>    specifies to which directory to change
        nice=<path>     specifies process priority of new process
        env:NAME=value  specifies a remote environment variable setting.

    If no spec is given, self.defaultspec is used.
    """

意思是你应该写:

gw = execnet.makegateway("popen//python=C:\\..\\jython2.7.0\\bin\\jython")

相关问题 更多 >

    热门问题