【发布时间】:2011-05-22 17:31:17
【问题描述】:
我的项目是这样设置的,它从一个 Java 类开始,该类使用 PythonInterpreter.initialize 方法将我的 python 路径设置为 jython Lib 目录和一个包含“org/curious/neofelis/我的 jython 文件”。然后我创建一个 PythonInterpreter 并让它执行我的主 jython 文件。
我猜这是非正统的,但它一直在工作,但是当我尝试使用 Popen 时出现此错误
File "/home/steven/jython/Lib/subprocess.py", line 1163, in _get_handles
elif isinstance(stdout, org.python.core.io.RawIOBase):
在尝试重现此错误时,我发现我可以做到这一点
from org.python.util import PythonInterpreter
#A PythonInterpreter running inside a PythonInterpreter!
interpreter = PythonInterpreter()
interpreter.exec("print 3+6");
sys.exit(0)
但这没有飞
import org
interpreter = org.python.util.PythonInterpreter()
interpreter.exec("print 3+6");
sys.exit(0)
File "/home/steven/neofelis/src/main/jython/org/curious/neofelis/main.py", line 34, in <module>
interpreter = org.python.util.PythonInterpreter()
AttributeError: 'module' object has no attribute 'python'
【问题讨论】:
标签: java python subprocess jython