无法在java

时间:2017-06-14 06:40:35

标签: java python

我必须从java调用example.py(有另一个依赖windrose,matlab,numpy)python文件来创建风图但是从java调用时它无法导入任何依赖但是它使用python独立运行,我得到< / p>

   Error: no module name windrose 

但是这个模块已经在文件夹中请告诉我怎么做

  windroseGraph ie = new windroseGraph();

  ie.execfile("E:\\example.py");

  PyInstance hello = ie.createClass("test", "None");

  hello.invoke("run");  

python文件example.py

  from windrose import WindroseAxes
  from numpy.random import random
  from numpy import arange
  from matplotlib import pyplot as plt
  import matplotlib.cm as cm


  class test:

     def new_axes():
        fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')
        rect = [0.1, 0.1, 0.8, 0.8]
        ax = WindroseAxes(fig, rect, axisbg='w')
        fig.add_axes(ax)
        return ax

     def set_legend(ax):
       l = ax.legend(borderaxespad=-0.10)
       plt.setp(l.get_texts(), fontsize=8)


     def run(self,wd,ws):

       ax = new_axes()
       ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
       set_legend(ax)

       ##print ax._info
       plt.show()

example.py是python文件,具有带参数的函数,并使用windrose.py模块生成风图(python lib online available)

0 个答案:

没有答案