Py4JNetworkError:无法连接到Java服务器

时间:2019-04-22 06:17:25

标签: java python apache-spark pyspark

我不熟悉将Spark用于大数据应用程序。由于某种原因,似乎pyspark无法连接到Java?

  
    
      

从pyspark导入SQLContext       sqlContext = SQLContext(sc)       错误:py4j.java_gateway:尝试连接到Java服务器时发生错误(127.0.0.1:50383)       追溯(最近一次通话):         文件“ C:\ Users \ CHESTER \ AppData \ Local \ Programs \ Python \ Python37-32 \ lib \ site-packages \ py4j \ java_gateway.py”,第929行,位于_get_connection中           连接= self.deque.pop()       IndexError:从一个空的双端队列弹出

    
  

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py4j\java_gateway.py", line 1067, in start
    self.socket.connect((self.address, self.port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
Traceback (most recent call last):
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py4j\java_gateway.py", line 929, in _get_connection
    connection = self.deque.pop()
IndexError: pop from an empty deque

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py4j\java_gateway.py", line 1067, in start
    self.socket.connect((self.address, self.port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "<pyshell#15>", line 1, in <module>
    sqlContext = SQLContext(sc)
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\sql\context.py", line 77, in __init__
    sparkSession = SparkSession.builder.getOrCreate()
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\sql\session.py", line 170, in getOrCreate
    sparkConf = SparkConf()
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\conf.py", line 116, in __init__
    self._jconf = _jvm.SparkConf(loadDefaults)
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py4j\java_gateway.py", line 1649, in __getattr__
    "\n" + proto.END_COMMAND_PART)
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py4j\java_gateway.py", line 983, in send_command
    connection = self._get_connection()
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py4j\java_gateway.py", line 931, in _get_connection
    connection = self._create_connection()
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py4j\java_gateway.py", line 937, in _create_connection
    connection.start()
  File "C:\Users\CHESTER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py4j\java_gateway.py", line 1079, in start
    raise Py4JNetworkError(msg, e)
py4j.protocol.Py4JNetworkError: An error occurred while trying to connect to the Java server (127.0.0.1:50383)

0 个答案:

没有答案