通过maven配置加载这个包,目前比较稳定的是python2.7的,见

        <dependency>
              <groupId>org.python</groupId>
              <artifactId>jython</artifactId>
              <version>2.7.0</version>
        </dependency>

然后运行个例子

 PythonInterpreter pyinterp = new PythonInterpreter();
 pyinterp.exec("days=('mod','Tue','Wed','Thu','Fri','Sat','Sun'); "); 
 pyinterp.exec("print days");

然后就挂了,显示一大堆错,吓死宝宝

ImportError: Cannot import site module and its dependencies

实际上只要设置了属性就不会再出现

 Properties props = new Properties();
 props.put("python.console.encoding", "UTF-8"); 
 props.put("python.security.respectJavaAccessibility", "false"); 
 props.put("python.import.site","false");
 Properties preprops = System.getProperties();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-01-07
相关资源
相似解决方案