# GWAS command error: py4j.protocol.Py4JNetworkError: Answer from Java side is empty

**URL:** <https://discuss.hail.is/t/gwas-command-error-py4j-protocol-py4jnetworkerror-answer-from-java-side-is-empty/727>\
**Category:** Hail Query & hailctl\
**Created:** [October 26, 2018, 7:22am UTC](https://discuss.hail.is/t/gwas-command-error-py4j-protocol-py4jnetworkerror-answer-from-java-side-is-empty/727 "2018-10-26T07:22:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![XuexiaSu](https://avatars.discourse-cdn.com/v4/letter/x/f6c823/32.png) [@XuexiaSu](https://discuss.hail.is/u/XuexiaSu)\
**Post date:** [October 26, 2018, 7:22am UTC](https://discuss.hail.is/t/gwas-command-error-py4j-protocol-py4jnetworkerror-answer-from-java-side-is-empty/727/1 "2018-10-26T07:22:41Z")

</div>

Do anyone know how to solve the error?  
Thanks so much!!!

gwas = hl.linear\_regression\_rows(y=common\_mt.CaffeineConsumption, x=common\_mt.GT.n\_alt\_alleles(), covariates=[1.0])  
gwas.row.describe()

2018-10-26 14:23:36 Hail: INFO: linear\_regression\_rows: running on 250 samples for 1 response variable y,  
with input variable x, and 1 additional covariate…  
ERROR:root:Exception while sending command.  
Traceback (most recent call last):  
File “/home/suxuexia/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py”, line 1159, 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 “/home/suxuexia/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py”, line 985, in send\_command  
response = connection.send\_command(command)  
File “/home/suxuexia/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py”, line 1164, in send\_command  
“Error while receiving”, e, proto.ERROR\_ON\_RECEIVE)  
py4j.protocol.Py4JNetworkError: Error while receiving

* * *

Py4JError Traceback (most recent call last)  
 in   
----\> 1 gwas = hl.linear\_regression\_rows(y=common\_mt.CaffeineConsumption, x=common\_mt.GT.n\_alt\_alleles(), covariates=[1.0])  
2 gwas.row.describe()

in linear\_regression\_rows(y, x, covariates, block\_size)

~/miniconda3/lib/python3.7/site-packages/hail/typecheck/check.py in wrapper(\_\_original\_func, \*args, \*\*kwargs)  
558 def wrapper(_original\_func, \*args, \*\*kwargs):  
559 args, kwargs_ = check\_all(\_\_original\_func, args, kwargs, checkers, is\_method=is\_method)  
–\> 560 return _original\_func(\*args, \*\*kwargs_)  
561  
562 return wrapper

~/miniconda3/lib/python3.7/site-packages/hail/methods/statgen.py in linear\_regression\_rows(y, x, covariates, block\_size)  
352 x\_field\_name,  
353 jarray(Env.jvm().java.lang.String, cov\_field\_names),  
–\> 354 block\_size)  
355  
356 ht\_result = Table(jt)

~/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py in **call** (self, \*args)  
1255 answer = self.gateway\_client.send\_command(command)  
1256 return\_value = get\_return\_value(  
-\> 1257 answer, self.gateway\_client, self.target\_id, self.name)  
1258  
1259 for temp\_arg in temp\_args:

~/miniconda3/lib/python3.7/site-packages/hail/utils/java.py in deco(\*args, \*\*kwargs)  
196 import pyspark  
197 try:  
–\> 198 return f(\*args, \*\*kwargs)  
199 except py4j.protocol.Py4JJavaError as e:  
200 s = e.java\_exception.toString()

~/miniconda3/lib/python3.7/site-packages/py4j/protocol.py in get\_return\_value(answer, gateway\_client, target\_id, name)  
334 raise Py4JError(  
335 “An error occurred while calling {0}{1}{2}”.  
–\> 336 format(target\_id, “.”, name))  
337 else:  
338 type = answer[1]

Py4JError: An error occurred while calling z:is.hail.methods.LinearRegression.apply

==============what I do next step=========================================

[suxuexia@localhost py4j]$ pip install py4j

Requirement already satisfied: py4j in /home/suxuexia/miniconda3/lib/python3.7/site-packages (0.10.7)

hail 0.2.2 has requirement ipykernel\<5, but you’ll have ipykernel 5.1.0 which is incompatible.

[suxuexia@localhost py4j]$ pip show ipykernel

[suxuexia@localhost py4j]$ pip uninstall ipykernel

[suxuexia@localhost py4j]$ pip install ipykernel

[suxuexia@localhost py4j]$ pip show ipykernel

Name: ipykernel

Version: 4.10.0

Summary: IPython Kernel for Jupyter

Home-page: [http://ipython.org](http://ipython.org)

Author: IPython Development Team

Author-email: [ipython-dev@scipy.org](mailto:ipython-dev@scipy.org)

License: BSD

Location: /home/suxuexia/miniconda3/lib/python3.7/site-packages

Requires: traitlets, ipython, tornado, jupyter-client

Required-by: notebook, hail

=========================generate a new error=======================================

gwas = hl.linear\_regression\_rows(y=common\_mt.CaffeineConsumption, x=common\_mt.GT.n\_alt\_alleles(), covariates=[1.0])  
gwas.row.describe()

ERROR:py4j.java\_gateway:An error occurred while trying to connect to the Java server (127.0.0.1:47944)  
Traceback (most recent call last):  
File “/home/suxuexia/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py”, line 929, in \_get\_connection  
connection = self.deque.pop()  
IndexError: pop from an empty deque

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/home/suxuexia/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py”, line 1067, in start  
self.socket.connect((self.address, self.port))  
ConnectionRefusedError: [Errno 111] Connection refused

* * *

IndexError Traceback (most recent call last)  
~/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py in \_get\_connection(self)  
928 try:  
–\> 929 connection = self.deque.pop()  
930 except IndexError:

IndexError: pop from an empty deque

During handling of the above exception, another exception occurred:

ConnectionRefusedError Traceback (most recent call last)  
~/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py in start(self)  
1066 try:  
-\> 1067 self.socket.connect((self.address, self.port))  
1068 self.stream = self.socket.makefile(“rb”)

ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Py4JNetworkError Traceback (most recent call last)  
 in   
----\> 1 gwas = hl.linear\_regression\_rows(y=common\_mt.CaffeineConsumption, x=common\_mt.GT.n\_alt\_alleles(), covariates=[1.0])  
2 gwas.row.describe()

in linear\_regression\_rows(y, x, covariates, block\_size)

~/miniconda3/lib/python3.7/site-packages/hail/typecheck/check.py in wrapper(\_\_original\_func, \*args, \*\*kwargs)  
558 def wrapper(_original\_func, \*args, \*\*kwargs):  
559 args, kwargs_ = check\_all(\_\_original\_func, args, kwargs, checkers, is\_method=is\_method)  
–\> 560 return _original\_func(\*args, \*\*kwargs_)  
561  
562 return wrapper

~/miniconda3/lib/python3.7/site-packages/hail/methods/statgen.py in linear\_regression\_rows(y, x, covariates, block\_size)  
345 row\_exprs=dict(mt.row\_key),  
346 col\_key=[],  
–\> 347 entry\_exprs={x\_field\_name: x})  
348  
349 jt = Env.hail().methods.LinearRegression.apply(

in \_select\_all(self, row\_exprs, row\_key, col\_exprs, col\_key, entry\_exprs, global\_exprs)

~/miniconda3/lib/python3.7/site-packages/hail/typecheck/check.py in wrapper(\_\_original\_func, \*args, \*\*kwargs)  
558 def wrapper(_original\_func, \*args, \*\*kwargs):  
559 args, kwargs_ = check\_all(\_\_original\_func, args, kwargs, checkers, is\_method=is\_method)  
–\> 560 return _original\_func(\*args, \*\*kwargs_)  
561  
562 return wrapper

~/miniconda3/lib/python3.7/site-packages/hail/matrixtable.py in \_select\_all(self, row\_exprs, row\_key, col\_exprs, col\_key, entry\_exprs, global\_exprs)  
2569 row\_struct = hl.struct(\*\*row\_exprs)  
2570 analyze(“MatrixTable.select\_rows”, row\_struct, self.\_row\_indices)  
-\> 2571 jmt = jmt.selectRows(str(row\_struct.\_ir))  
2572 if row\_key is not None:  
2573 jmt = jmt.keyRowsBy(row\_key)

~/miniconda3/lib/python3.7/site-packages/hail/ir/base\_ir.py in **str** (self)  
8 def **str** (self):  
9 r = Renderer(stop\_at\_jir = False)  
—\> 10 return r(self)  
11  
12 class IR(BaseIR):

~/miniconda3/lib/python3.7/site-packages/hail/ir/renderer.py in **call** (self, x)  
24 return f’(JavaIR {jir\_id})’  
25 else:  
—\> 26 return x.render(self)

~/miniconda3/lib/python3.7/site-packages/hail/ir/ir.py in render(self, r)  
944  
945 def render(self, r):  
–\> 946 return ‘(MakeStruct {})’.format(’ ‘.join([’({} {})’.format(escape\_id(f), r(x)) for (f, x) in self.fields]))  
947  
948 def **eq** (self, other):

~/miniconda3/lib/python3.7/site-packages/hail/ir/ir.py in (.0)  
944  
945 def render(self, r):  
–\> 946 return ‘(MakeStruct {})’.format(’ ‘.join([’({} {})’.format(escape\_id(f), r(x)) for (f, x) in self.fields]))  
947  
948 def **eq** (self, other):

~/miniconda3/lib/python3.7/site-packages/hail/utils/java.py in escape\_id(s)  
165  
166 def escape\_id(s):  
–\> 167 return Env.jutils().escapeIdentifier(s)  
168  
169 def jarray\_to\_list(a):

~/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py in **call** (self, \*args)  
1253 proto.END\_COMMAND\_PART  
1254  
-\> 1255 answer = self.gateway\_client.send\_command(command)  
1256 return\_value = get\_return\_value(  
1257 answer, self.gateway\_client, self.target\_id, self.name)

~/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py in send\_command(self, command, retry, binary)  
981 if `binary` is `True`.  
982 “”"  
–\> 983 connection = self.\_get\_connection()  
984 try:  
985 response = connection.send\_command(command)

~/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py in \_get\_connection(self)  
929 connection = self.deque.pop()  
930 except IndexError:  
–\> 931 connection = self.\_create\_connection()  
932 return connection  
933

~/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py in \_create\_connection(self)  
935 connection = GatewayConnection(  
936 self.gateway\_parameters, self.gateway\_property)  
–\> 937 connection.start()  
938 return connection  
939

~/miniconda3/lib/python3.7/site-packages/py4j/java\_gateway.py in start(self)  
1077 “server ({0}:{1})”.format(self.address, self.port)  
1078 logger.exception(msg)  
-\> 1079 raise Py4JNetworkError(msg, e)  
1080  
1081 def \_authenticate\_connection(self):

Py4JNetworkError: An error occurred while trying to connect to the Java server (127.0.0.1:47944)
