findspark.init() IndexError: list index out of range error
findspark.init() IndexError: list index out of range error
当 运行 在 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')
之后,应该一切正常!
我遇到了同样的错误,并且能够通过输入确切的安装目录使其正常工作:
import findspark
# Use this
findspark.init("C:\Users\PolestarEmployee\spark-1.6.3-bin-hadoop2.6")
# Test
from pyspark import SparkContext, SparkConf
Basically, it is the directory where spark was extracted. In future where ever you see spark_home
enter the same installation directory.
I also tried using toree to create a kernal instead, but it is failing somehow. A kernal would be a cleaner solution.
您需要更新 bash_profile 中的 SPARK_HOME
变量。
对我来说,以下命令有效(在终端中):
export SPARK_HOME="/usr/local/Cellar/apache-spark/2.2.0/libexec/"
在此之后,您可以使用以下命令:
import findspark
findspark.init('/usr/local/Cellar/apache-spark/2.2.0/libexec')
也许这会有所帮助:
我发现 findspark.init() 尝试在 .\spark-3.0.1-bin-hadoop2.7\bin\python\lib 中查找数据,但 python 文件夹在 bin 之外文件夹。
我只是 运行 findspark.init('.\spark-3.0.1-bin-hadoop2.7'), 没有 '\bin' 文件夹
当 运行 在 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')
之后,应该一切正常!
我遇到了同样的错误,并且能够通过输入确切的安装目录使其正常工作:
import findspark
# Use this
findspark.init("C:\Users\PolestarEmployee\spark-1.6.3-bin-hadoop2.6")
# Test
from pyspark import SparkContext, SparkConf
Basically, it is the directory where spark was extracted. In future where ever you see
spark_home
enter the same installation directory. I also tried using toree to create a kernal instead, but it is failing somehow. A kernal would be a cleaner solution.
您需要更新 bash_profile 中的 SPARK_HOME
变量。
对我来说,以下命令有效(在终端中):
export SPARK_HOME="/usr/local/Cellar/apache-spark/2.2.0/libexec/"
在此之后,您可以使用以下命令:
import findspark
findspark.init('/usr/local/Cellar/apache-spark/2.2.0/libexec')
也许这会有所帮助:
我发现 findspark.init() 尝试在 .\spark-3.0.1-bin-hadoop2.7\bin\python\lib 中查找数据,但 python 文件夹在 bin 之外文件夹。 我只是 运行 findspark.init('.\spark-3.0.1-bin-hadoop2.7'), 没有 '\bin' 文件夹