【问题标题】:Unable to create spark context on Jupyter Notebook无法在 Jupyter Notebook 上创建火花上下文
【发布时间】:2018-11-24 03:30:36
【问题描述】:

谁能帮助我在创建 Spark 上下文时遇到错误? 我无法创建,因为我收到以下错误

from pyspark import SparkConf,SparkContext

conf=SparkConf().setMaster("localhost")
sc=SparkContext(conf = conf)


ExceptionTraceback (most recent call last)
<ipython-input-7-3d97d6624879> in <module>()
----> 1 sc=SparkContext(conf = conf)

/home/cloudera/anaconda2/lib/python2.7/site-packages/pyspark/context.pyc in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
    113         """
    114         self._callsite = first_spark_call() or CallSite(None, None, None)
--> 115         SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
    116         try:
    117             self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,

/home/cloudera/anaconda2/lib/python2.7/site-packages/pyspark/context.pyc in _ensure_initialized(cls, instance, gateway, conf)
    296         with SparkContext._lock:
    297             if not SparkContext._gateway:
--> 298                 SparkContext._gateway = gateway or launch_gateway(conf)
    299                 SparkContext._jvm = SparkContext._gateway.jvm
    300 

/home/cloudera/anaconda2/lib/python2.7/site-packages/pyspark/java_gateway.pyc in launch_gateway(conf)
     92 
     93             if not os.path.isfile(conn_info_file):
---> 94                 raise Exception("Java gateway process exited before sending its port number")
     95 
     96             with open(conn_info_file, "rb") 

Exception: Java gateway process exited before sending its port number

【问题讨论】:

标签: python apache-spark


【解决方案1】:

当您的 PySpark 版本与您设置的 Spark 版本不匹配时,可能会发生这种情况。 (由SPARK_HOME 变量决定)- 我记得这是很久以前的问题了。

在你的终端上,尝试做

pip freeze|grep pyspark

然后

spark-shell --version

确保版本匹配。如果是这样,请重新启动内核并重试。希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2016-05-24
    • 1970-01-01
    • 2016-09-07
    • 1970-01-01
    • 2018-07-10
    • 1970-01-01
    • 1970-01-01
    • 2016-03-01
    • 2021-09-30
    相关资源
    最近更新 更多