I'm trying to execute Python script from java and returning some value from Script to java.
here is my java code CallPY.java:
Properties properties = System.getProperties();
properties.put("python.path", "/home/abcd/Downloads/");
PythonInterpreter.initialize(System.getProperties(), properties, new String[0]);
this.interpreter = new PythonInterpreter();
this.interpreter.execfile("/home/abcd/Downloads/hello.py");
PyInstance hello = ie.createClass("Hello", "None");
PyObject result = hello.invoke("def_Name",
new PyString("value_1"), new PyString("value_2"));
and
my Python code is hello.py:
import sys
sys.path.append('/usr/local/lib/python2.7/dist-packages')
import pandas as pd
import numpy as np
import matplotlib
class Hello:
__gui = None
def __init__(self, gui):
self.__gui = gui
def def_Name(self, value_1, value_):
s={"Key" : "Value"}
print value_1, " ", value_2
return s
I need numpy, panda and matplotlib for future needs and some other modules as well. While executing java file I'm getting error as:
import pandas as pd
File "/usr/local/lib/python2.7/dist-packages/pandas/__init__.py", line 14
except ImportError as e:
^
SyntaxError: mismatched input 'as' expecting COLON
There are no issues while running the Python script from console and Jupyter, so there is same issue with java code. Please point me how to fix the issue.
Thanks in Advance.