0

I have to call example.py (having another dependencies windrose, matlab, numpy ) python file from java to create wind graph but it unable to import any dependency while calling from java but its runs fine independently using python, I got

   Error: no module name windrose 

but this module is already in folder please let me know how to do it

  windroseGraph ie = new windroseGraph();

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

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

  hello.invoke("run");  

python file 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 is python file having function with parameter and generate wind graph using windrose.py module (python lib online available )

4
  • please show us the python file, as well Commented Jun 14, 2017 at 6:44
  • see this: stackoverflow.com/questions/28487118/… Commented Jun 14, 2017 at 7:01
  • how could I pass the parameter to the python function (as required in my example ) and Is it required to install python Commented Jun 14, 2017 at 7:13
  • I m new for python can u explain using my example Commented Jun 14, 2017 at 7:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.