在 Python 3.5 Jupyter 环境中运行以下命令时,出现以下错误。关于造成它的原因有什么想法吗?
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
时指定它,如下所示:
import findspark
findspark.init('/path/to/spark/home')
在那之后,它应该一切正常!
关于python - findspark.init() 索引错误 : list index out of range error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42223498/