Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x findspark.init()列表索引超出范围错误_Python 3.x_Pyspark_Jupyter Notebook - Fatal编程技术网

Python 3.x findspark.init()列表索引超出范围错误

Python 3.x findspark.init()列表索引超出范围错误,python-3.x,pyspark,jupyter-notebook,Python 3.x,Pyspark,Jupyter Notebook,当使用findspark.find()时,我得到了安装spark的路径,但是当尝试findspark.init(path)时,我得到了一个列表索引超出了使用jupyter笔记本的范围的错误 我已确保SPARK_HOME和PATH变量也已正确设置 下面的代码输出火花主路径 使用上述spark主路径的输出进行初始化 抛出列表索引超出范围错误 我不明白它如何输出正确的路径,但无法初始化spark我通过将spark和Hadoop目录移动到安装了anaconda和jupyter的C驱动器来解决这个问题。然

当使用findspark.find()时,我得到了安装spark的路径,但是当尝试findspark.init(path)时,我得到了一个列表索引超出了使用jupyter笔记本的范围的错误

我已确保SPARK_HOME和PATH变量也已正确设置

下面的代码输出火花主路径

使用上述spark主路径的输出进行初始化

抛出列表索引超出范围错误


我不明白它如何输出正确的路径,但无法初始化spark

我通过将spark和Hadoop目录移动到安装了anaconda和jupyter的C驱动器来解决这个问题。然后更新SPARK_HOME和PATH环境变量以反映新的目的地


提交上述更改并重新启动终端后,我能够通过jupyter笔记本连接到spark并执行代码

我通过将Spark和Hadoop目录移动到安装了anaconda和jupyter的C驱动器来解决这个问题。然后更新SPARK_HOME和PATH环境变量以反映新的目的地

提交上述更改并重新启动终端后,我能够通过jupyter笔记本连接到spark并执行代码

import findspark
findspark.find()
import findspark
findspark.init(path)
    133     # add pyspark to sys.path
    134     spark_python = os.path.join(spark_home, 'python')
--> 135     py4j = glob(os.path.join(spark_python, 'lib', 'py4j-*.zip'))[0]
    136     sys.path[:0] = [spark_python, py4j]
    137 

    IndexError: list index out of range