问题描述
我尝试使用加载 JSON 文件,koalas
但它抛出连接被拒绝错误。如果我在这里遗漏任何东西,有人可以帮我解决这个问题吗?
包版本
Pyspark : '2.4.3'
koalas: '0.19.0'
Python : Python 3.6.9 :: Anaconda, Inc.
代码片段
import databricks.koalas as ks
data = ks.read_json('dataset/mydata.json')
data.head()
错误
ERROR:py4j.java_gateway:An error occurred while trying to connect to the Java server (127.0.0.1:50306)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_gateway.py", line 1067, in start
self.socket.connect((self.address, self.port))
ConnectionRefusedError: [Errno 61] Connection refused
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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 61] Connection refused
During handling of the above exception, another exception occurred:
Py4JNetworkError Traceback (most recent call last)
<ipython-input-7-06373fe8f71d> in <module>
----> 1 job = ks.read_json('data/job/job_tenant_ingersollauto_0.json')
2 job.head()
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/databricks/koalas/namespace.py in read_json(path, index_col, **options)
282 1 c d
283 """
--> 284 return read_spark_io(path, format='json', index_col=index_col, options=options)
285
286
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/databricks/koalas/namespace.py in read_spark_io(path, format, schema, index_col, **options)
411 0 0
412 """
--> 413 sdf = default_session().read.load(path=path, format=format, schema=schema, options=options)
414 index_map = _get_index_map(sdf, index_col)
415
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/databricks/koalas/utils.py in default_session(conf)
267 for key, value in conf.items():
268 builder = builder.config(key, value)
--> 269 return builder.getOrCreate()
270
271
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyspark/sql/session.py in getOrCreate(self)
181 session = SparkSession(sc)
182 for key, value in self._options.items():
--> 183 session._jsparkSession.sessionState().conf().setConfString(key, value)
184 for key, value in self._options.items():
185 session.sparkContext._conf.set(key, value)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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:50306)