我的项目设置如下,它从一个Java类开始,它使用PythonInterpreter.initialize方法将我的python设置为jython目录和一个包含“org/好奇心/neofelis/ method文件”的目录。然后创建一个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'发布于 2010-12-09 08:42:31
导入一个包--在本例中是org --并不总是导入它的所有子包和子模块。需要由包来定义在执行import org时将包含哪些内容。显然,默认情况下导入中不包含python子包,因此需要显式导入它。
https://stackoverflow.com/questions/4396288
复制相似问题