首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关于py4j异常

关于py4j异常
EN

Stack Overflow用户
提问于 2019-01-11 23:04:05
回答 1查看 531关注 0票数 1

我已经在CentOS上安装了Java11和Python3。试图运行一段在Windows环境下运行得很好的代码。获取此异常:

代码语言:javascript
复制
ERROR:root:Exception while sending command.
Traceback (most recent call last):
File "/usr/lib/python3.4/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 "/usr/lib/python3.4/site-packages/py4j/java_gateway.py", line 1014, in send_command
response = connection.send_command(command)
File "/usr/lib/python3.4/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 "WordInformation.py", line 493, in 
status = read_from_source("../Corpora/Bhandarkar Oriental Research Books") 

File "WordInformation.py", line 473, in read_from_source
author, year)
File "WordInformation.py", line 381, in fetch_from_hwn
return read_store_properties(word, file, sentence, source, category, author, 
year);
File "WordInformation.py", line 79, in read_store_properties
properties["synsets"] = get_other_props(word)
File "WordInformation.py", line 226, in get_other_props
output = gateway.jvm.Properties.getProperties(word)
File "/usr/lib/python3.4/site-packages/py4j/java_gateway.py", line 1286, in 
call
answer, self.gateway_client, self.target_id, self.name)
File "/usr/lib/python3.4/site-packages/py4j/protocol.py", line 336, in 
get_return_value
format(target_id, ".", name))
py4j.protocol.Py4JError: An error occurred while calling 
z:in.ac.iitb.cfilt.jhwnl.examples.Properties.getProperties

按如下方式初始化网关:gateway = JavaGateway.launch_gateway(classpath="/home/gayatri/Code/hindiwn.jar")这是因为依赖吗?我已经设置了JAVA_HOME并更新了PATH变量。

EN

回答 1

Stack Overflow用户

发布于 2020-04-17 10:31:08

我没什么好说的,但是

代码语言:javascript
复制
Answer from Java side is empty

但是这个错误表明Java代码是不可访问的。只是为了验证基本步骤

1)确保java程序正在运行

2)确保在java代码运行之后运行Python脚本

3) java程序一直在运行。

如果您正在做这两件事,那么一个问题可能是操作系统可能已经在使用一个端口。

你可以试试

Java

代码语言:javascript
复制
'GatewayServerBuilder server = new GatewayServerBuilder().javaPort(1001).build()'
'server.start()'

Python

代码语言:javascript
复制
java = JavaGateway(gateway_parameters=GatewayParameters(port=1001))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54149088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档