Python 3.x 无法在考拉中加载JSON文件,获取连接被拒绝错误
问题描述 我试图使用Python 3.x 无法在考拉中加载JSON文件,获取连接被拒绝错误,python-3.x,pyspark,spark-koalas,Python 3.x,Pyspark,Spark Koalas,问题描述 我试图使用koalas加载一个JSON文件,但它抛出了连接拒绝错误。 如果我遗漏了什么,有人能帮我解决这个问题吗 软件包版本 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.
koalas
加载一个JSON文件,但它抛出了连接拒绝错误。
如果我遗漏了什么,有人能帮我解决这个问题吗
软件包版本
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)
错误:py4j.java_网关:尝试连接到java服务器时出错(127.0.0.1:50306)
回溯(最近一次呼叫最后一次):
文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_-gateway.py”,第929行,在_-get_-connection中
连接=self.deque.pop()
索引器:从空文件中弹出
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site packages/py4j/java_gateway.py”,第1067行,开头
self.socket.connect((self.address,self.port))
ConnectionRefusedError:[Errno 61]连接被拒绝
---------------------------------------------------------------------------
索引器回溯(最后一次最近调用)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_gateway.py in_get_connection(self)
928请尝试:
-->929连接=self.deque.pop()
930除索引器外:
索引器:从空文件中弹出
在处理上述异常期间,发生了另一个异常:
ConnectionRefuedError回溯(最近一次调用上次)
/开始时的Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_gateway.py(self)
1066尝试:
->1067 self.socket.connect((self.address,self.port))
1068 self.stream=self.socket.makefile(“rb”)
ConnectionRefusedError:[Errno 61]连接被拒绝
在处理上述异常期间,发生了另一个异常:
Py4JNetworkError回溯(上次最近的调用)
在里面
---->1 job=ks.read\u json('data/job/job\u tenant\u ingersollauto\u 0.json'))
2.职位主管()
/read_json中的Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/databricks/koalas/namespace.py(路径、索引列、**选项)
2821CD
283 """
-->284返回read\u spark\u io(路径,format='json',index\u col=index\u col,options=options)
285
286
/read_spark_io中的Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/databricks/koalas/namespace.py(路径、格式、模式、索引列、**选项)
411 0 0
412 """
-->413 sdf=默认会话().read.load(路径=路径,格式=格式,模式=模式,选项=选项)
414索引映射=\u获取索引映射(sdf,索引列)
415
/默认会话(conf)中的Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/databricks/koalas/utils.py
267对于键,conf.items()中的值:
268 builder=builder.config(键,值)
-->269返回生成器。getOrCreate()
270
271
/getOrCreate(self)中的Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyspark/sql/session.py
181会话=SparkSession(sc)
182对于键,值在self.\u options.items()中:
-->183 session._jsparkSession.sessionState().conf().setConfString(键,值)
184对于键,值在self.\u options.items()中:
185 session.sparkContext._conf.set(键,值)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_gateway.py in__调用(self,*args)
1253协议结束命令部分
1254
->1255 answer=self.gateway\u client.send\u命令(command)
1256返回值=获取返回值(
1257应答,self.gateway_客户端,self.target_id,self.name)
/send_命令中的Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_gateway.py(self、command、retry、binary)
981如果'binary'为'True'。
982 """
-->983连接=self.\u获取\u连接()
984尝试:
985响应=连接。发送命令(命令)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_gateway.py in_get_connection(self)
929连接=self.deque.pop()
930除索引器外:
-->931连接=self.\u创建\u连接()
932回路连接
933
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_gateway.py in_create_connection(self)
935连接=网关连接(
936 self.gateway_参数,self.gateway_属性)
-->937连接。开始()
938回路连接
939
/开始时的Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/py4j/java_gateway.py(self)
1077“服务器({0}:{1})”。格式(self.address,self.port)
1078记录器。异常(msg)
->1079引发Py4JNetworkError(消息,e)
1080
1081 def_认证_连接(自):
Py4JNetworkError:尝试连接到Java服务器时出错(127.0.0.1:50306)