jupyter笔记本中的pyspark问题

rlcwz9us  于 2021-05-27  发布在  Spark
关注(0)|答案(0)|浏览(926)

初始化时出现此错误。我已经设置了大师和工人,然后开始这个…虽然设置大师和Spark后,我没有启动Spark壳直接运行这个。有人能帮忙吗。。
代码:

import findspark
import os
os.environ["SPARK_HOME"]="C:\Spark"
findspark.init()
from pyspark.sql import SparkSession
from pyspark import SparkConf, SparkContext

错误:

IndexError                                Traceback (most recent call last)
c:\users\khan\appdata\local\programs\python\python37\lib\site-packages\findspark.py in init(spark_home, python_path, edit_rc, edit_profile)
    142     try:
--> 143         py4j = glob(os.path.join(spark_python, "lib", "py4j-*.zip"))[0]
    144     except IndexError:

IndexError: list index out of range

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-7-db62de47bcf3> in <module>
      2 import os
      3 os.environ["SPARK_HOME"]="C:\Spark"
----> 4 findspark.init()
      5 from pyspark.sql import SparkSession
      6 from pyspark import SparkConf, SparkContext

c:\users\khan\appdata\local\programs\python\python37\lib\site-packages\findspark.py in init(spark_home, python_path, edit_rc, edit_profile)
    144     except IndexError:
    145         raise Exception(
--> 146             "Unable to find py4j, your SPARK_HOME may not be configured correctly"
    147         )
    148     sys.path[:0] = [spark_python, py4j]

Exception: Unable to find py4j, your SPARK_HOME may not be configured correctly

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题