java导入错误:Jython中没有名为demiso的模块
我是Jython新手,我正在尝试在Java中使用Jython运行python类。但我遇到了一些问题
The Java class that I've defined:
public class DemistoCalls {
PythonInterpreter interpreter = null;
public DemistoCalls()
{
PythonInterpreter.initialize(System.getProperties(),
System.getProperties(), new String[0]);
this.interpreter = new PythonInterpreter();
}
void execfile( final String fileName )
{
this.interpreter.execfile(fileName);
}
PyInstance createClass( final String className, final String opts )
{
return (PyInstance) this.interpreter.eval(className + "(" + opts + ")");
}
public static void main(String[] args) {
DemistoCalls demistoCalls = new DemistoCalls();
demistoCalls.execfile("C:\\Users\\AlokNath\\Desktop\\Demisto_Project\\demisto-py-master\\demisto\\SimpleConnect.py");
}
}
The SampleConnect.py file that I'm trying to run:
import sys
sys.path.append("C:\Users\AlokNath\Desktop\Demisto_Project\demisto-py-
master\demisto")
import demisto
运行java文件时,我遇到以下错误:
File "C:\Users\AlokNath\Desktop\Demisto_Project\demisto-py-master\demisto\SimpleConnect.py", line 3, in <module>
import demisto
ImportError: No module named demisto
尽管我在系统路径中定义了“demisto”模块,并检查了python中的系统路径是否包含到Jython 2.7的适当路径。lb2图书馆。我不知道我哪里出了问题。感谢您的帮助
问候,, 阿洛克
# 1 楼答案
我找到了导入错误问题的解决方案。我们需要将缺少的模块复制到“modeler安装/lib/jython/lib”下的“site packages”文件夹中。这将解决依赖性问题