findspark.init()IndexError:列表索引超出范围错误 [英] findspark.init() IndexError: list index out of range error

查看:299
本文介绍了findspark.init()IndexError:列表索引超出范围错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Python 3.5 Jupyter环境中运行以下命令时,出现以下错误.有什么原因引起的想法吗?

When running the following in a Python 3.5 Jupyter environment I get the error below. Any ideas on what is causing it?

import findspark
findspark.init()

错误:

IndexError                                Traceback (most recent call
last) <ipython-input-20-2ad2c7679ebc> in <module>()
      1 import findspark
----> 2 findspark.init()
      3 
      4 import pyspark

/.../anaconda/envs/pyspark/lib/python3.5/site-packages/findspark.py in init(spark_home, python_path, edit_rc, edit_profile)
    132     # add pyspark to sys.path
    133     spark_python = os.path.join(spark_home, 'python')
--> 134     py4j = glob(os.path.join(spark_python, 'lib', 'py4j-*.zip'))[0]
    135     sys.path[:0] = [spark_python, py4j]
    136 

IndexError: list index out of range

推荐答案

这很可能是由于SPARK_HOME环境变量未在系统上正确设置.另外,您也可以在初始化findspark时指定它,就像这样:

This is most likely due to the SPARK_HOME environment variable not being set correctly on your system. Alternatively, you can just specify it when you're initialising findspark, like so:

import findspark
findspark.init('/path/to/spark/home')

在那之后,它应该都可以工作!

After that, it should all work!

这篇关于findspark.init()IndexError:列表索引超出范围错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆