Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py4j.protocol.Py4JNetworkError: Answer from Java side is empty #2

Closed
Harpsichord1207 opened this issue Feb 1, 2019 · 7 comments
Closed

Comments

@Harpsichord1207
Copy link

Harpsichord1207 commented Feb 1, 2019

I copied the code in readme except replace the pmml file and csv file , and then raise a error.

Code:

from jpmml_evaluator import launch_gateway

gateway = launch_gateway()

from jpmml_evaluator import Evaluator, LoadingModelEvaluatorBuilder

evaluatorBuilder = LoadingModelEvaluatorBuilder(gateway) \
	.setLocatable(True) \
	.loadFile("model.pmml")

evaluator = evaluatorBuilder.build() \
	.verify()


import pandas

arguments_df = pandas.read_csv("Churn.csv", sep = ",")

results_df = evaluator.evaluateAll(arguments_df)
print(results_df)

gateway.shutdown()

Error:

E:\MachineLearning\venv\Scripts\python.exe E:/MachineLearning/GeekWeek/main.py
ERROR:root:Exception while sending command.
Traceback (most recent call last):
  File "E:\MachineLearning\venv\lib\site-packages\py4j\java_gateway.py", line 1188, in send_command
    raise Py4JNetworkError("Answer from Java side is empty")
py4j.protocol.Py4JNetworkError: Answer from Java side is empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\MachineLearning\venv\lib\site-packages\py4j\java_gateway.py", line 1014, in send_command
    response = connection.send_command(command)
  File "E:\MachineLearning\venv\lib\site-packages\py4j\java_gateway.py", line 1193, in send_command
    "Error while receiving", e, proto.ERROR_ON_RECEIVE)
py4j.protocol.Py4JNetworkError: Error while receiving
Traceback (most recent call last):
  File "E:/MachineLearning/GeekWeek/main.py", line 8, in <module>
    .setLocatable(True) \
  File "E:\MachineLearning\venv\lib\site-packages\jpmml_evaluator\__init__.py", line 110, in setLocatable
    self.javaModelEvaluatorBuilder.setLocatable(locatable)
  File "E:\MachineLearning\venv\lib\site-packages\py4j\java_gateway.py", line 1286, in __call__
    answer, self.gateway_client, self.target_id, self.name)
  File "E:\MachineLearning\venv\lib\site-packages\py4j\protocol.py", line 336, in get_return_value
    format(target_id, ".", name))
py4j.protocol.Py4JError: An error occurred while calling o0.setLocatable

Process finished with exit code 1

@vruusmann
Copy link
Member

py4j.protocol.Py4JNetworkError: Answer from Java side is empty

This is a generic Py4J layer error. The execution gets stuck when launching the Py4J gateway, because there doesn't seem to be a Java installation available.

Do you have Java 1.8 (or newer) installed and available on system path? To test it, open a command prompt, and type java -version. What do you see?

@Harpsichord1207
Copy link
Author

@vruusmann Thanks for replying, Yes I have a java, maybe the version is incompatible?

$ java -version
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

@vruusmann
Copy link
Member

vruusmann commented Feb 1, 2019

Version 11(.0.2) is definitely newer/greater than the minimum required version 8.

There shouldn't be any problems with Java 11 from the JPMML-Evaluator library perspective. But perhaps there are some issues with the Py4J "carrier layer" perspective.

You should try making a parallel Java 8 installation into your computer. Then, export to the location of the Java 8 installation as JAVA_HOME environment variable (AFAIK, this is how Py4J locates the Java version to use), and try again.

@vruusmann
Copy link
Member

Thanks, I solved the problem by changing all "Interger" to "Double" in the pmml file.

@Harpsichord1207 This is no real solution. One cannot go on manually correcting PMML files. You should really inform the KNIME team about this issue, and ask them to fix their software.

@Harpsichord1207
Copy link
Author

Version 11(.0.2) is definitely newer/greater than the minimum required version 8.

There shouldn't be any problems with Java 11 from the JPMML-Evaluator library perspective. But perhaps there are some issues with the Py4J "carrier layer" perspective.

You should try making a parallel Java 8 installation into your computer. Then, export to the location of the Java 8 installation as JAVA_HOME environment variable (AFAIK, this is how Py4J locates the Java version to use), and try again.

I install a Java 8, and get the same error:

$ java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

@Harpsichord1207
Copy link
Author

Thanks, I solved the problem by changing all "Interger" to "Double" in the pmml file.

@Harpsichord1207 This is no real solution. One cannot go on manually correcting PMML files. You should really inform the KNIME team about this issue, and ask them to fix their software.

Thanks, I'll feed back this issue to KNIME team.

@vruusmann
Copy link
Member

It's now possible to choose between PyJNIus and Py4J backends (see the README file).

Please give the PyJNIus backend a try (if the Py4J backend keeps failing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants